@@ -49,24 +49,15 @@ std::shared_ptr<Schema> CreateTestSchema() {
4949 return std::make_shared<Schema>(std::vector<SchemaField>{field1, field2, field3}, 0 );
5050}
5151
52- // Helper function to create a simple schema with invalid identifier fields
53- std::shared_ptr<Schema> CreateInvalidSchema () {
54- auto field1 = SchemaField::MakeRequired (2 , " id" , int32 ());
55- auto field2 = SchemaField::MakeRequired (5 , " part_col" , string ());
56- auto field3 = SchemaField::MakeRequired (8 , " sort_col" , timestamp ());
57- return std::make_shared<Schema>(std::vector<SchemaField>{field1, field2, field3},
58- /* schema_id=*/ 1 ,
59- /* identifier_field_ids=*/ std::vector<int32_t >{10 });
60- }
61-
6252// Helper function to create a simple schema with disordered field_ids
63- std::shared_ptr <Schema> CreateDisorderedSchema () {
53+ Result< std::unique_ptr <Schema> > CreateDisorderedSchema () {
6454 auto field1 = SchemaField::MakeRequired (2 , " id" , int32 ());
6555 auto field2 = SchemaField::MakeRequired (5 , " part_col" , string ());
6656 auto field3 = SchemaField::MakeRequired (8 , " sort_col" , timestamp ());
67- return std::make_shared<Schema>(std::vector<SchemaField>{field1, field2, field3},
68- /* schema_id=*/ 1 ,
69- /* identifier_field_ids=*/ std::vector<int32_t >{2 });
57+
58+ return Schema::Make (std::vector<SchemaField>{field1, field2, field3},
59+ /* schema_id=*/ 1 ,
60+ /* identifier_field_ids=*/ std::vector<int32_t >{2 });
7061}
7162
7263// Helper function to create base metadata for tests
@@ -95,7 +86,7 @@ std::unique_ptr<TableMetadata> CreateBaseMetadata() {
9586
9687// test for TableMetadata
9788TEST (TableMetadataTest, Make) {
98- auto Schema = CreateDisorderedSchema ();
89+ ICEBERG_UNWRAP_OR_FAIL ( auto Schema, CreateDisorderedSchema () );
9990 ICEBERG_UNWRAP_OR_FAIL (
10091 auto spec, PartitionSpec::Make (1 , std::vector<PartitionField>{PartitionField (
10192 5 , 1 , " part_name" , Transform::Identity ())}));
@@ -140,23 +131,8 @@ TEST(TableMetadataTest, Make) {
140131 EXPECT_EQ (NullOrder::kLast , order_fields[0 ].null_order ());
141132}
142133
143- TEST (TableMetadataTest, MakeWithInvalidSchema) {
144- auto schema = CreateInvalidSchema ();
145- ICEBERG_UNWRAP_OR_FAIL (
146- auto spec, PartitionSpec::Make (1 , std::vector<PartitionField>{PartitionField (
147- 5 , 1 , " part_name" , Transform::Identity ())}));
148- ICEBERG_UNWRAP_OR_FAIL (
149- auto order, SortOrder::Make (1 , std::vector<SortField>{SortField (
150- 5 , Transform::Identity (),
151- SortDirection::kAscending , NullOrder::kLast )}));
152-
153- auto res = TableMetadata::Make (*schema, *spec, *order, " s3://bucket/test" , {});
154- EXPECT_THAT (res, IsError (ErrorKind::kInvalidSchema ));
155- EXPECT_THAT (res, HasErrorMessage (" Cannot find identifier field id" ));
156- }
157-
158134TEST (TableMetadataTest, MakeWithInvalidPartitionSpec) {
159- auto schema = CreateDisorderedSchema ();
135+ ICEBERG_UNWRAP_OR_FAIL ( auto schema, CreateDisorderedSchema () );
160136 ICEBERG_UNWRAP_OR_FAIL (
161137 auto spec, PartitionSpec::Make (1 , std::vector<PartitionField>{PartitionField (
162138 6 , 1 , " part_name" , Transform::Identity ())}));
@@ -171,7 +147,7 @@ TEST(TableMetadataTest, MakeWithInvalidPartitionSpec) {
171147}
172148
173149TEST (TableMetadataTest, MakeWithInvalidSortOrder) {
174- auto schema = CreateDisorderedSchema ();
150+ ICEBERG_UNWRAP_OR_FAIL ( auto schema, CreateDisorderedSchema () );
175151 ICEBERG_UNWRAP_OR_FAIL (
176152 auto spec, PartitionSpec::Make (1 , std::vector<PartitionField>{PartitionField (
177153 5 , 1 , " part_name" , Transform::Identity ())}));
@@ -191,7 +167,7 @@ TEST(TableMetadataTest, InvalidProperties) {
191167
192168 {
193169 // Invalid metrics config
194- auto schema = CreateDisorderedSchema ();
170+ ICEBERG_UNWRAP_OR_FAIL ( auto schema, CreateDisorderedSchema () );
195171 std::unordered_map<std::string, std::string> invlaid_metric_config = {
196172 {std::string (TableProperties::kMetricModeColumnConfPrefix ) + " unknown_col" ,
197173 " value" }};
@@ -204,7 +180,7 @@ TEST(TableMetadataTest, InvalidProperties) {
204180
205181 {
206182 // Invaid commit properties
207- auto schema = CreateDisorderedSchema ();
183+ ICEBERG_UNWRAP_OR_FAIL ( auto schema, CreateDisorderedSchema () );
208184 std::unordered_map<std::string, std::string> invlaid_commit_properties = {
209185 {TableProperties::kCommitNumRetries .key (), " -1" }};
210186
0 commit comments