@@ -44,35 +44,41 @@ class MetadataIOTest : public TempFileTestBase {
4444 temp_filepath_ = CreateNewTempFilePathWithSuffix (" .metadata.json" );
4545 }
4646
47+ TableMetadata PrepareMetadata () {
48+ std::vector<SchemaField> schema_fields;
49+ schema_fields.emplace_back (/* field_id=*/ 1 , " x" , std::make_shared<LongType>(),
50+ /* optional=*/ false );
51+ auto schema = std::make_shared<Schema>(std::move (schema_fields), /* schema_id=*/ 1 );
52+
53+ TableMetadata metadata{
54+ .format_version = 1 ,
55+ .table_uuid = " 1234567890" ,
56+ .location = " s3://bucket/path" ,
57+ .last_sequence_number = 0 ,
58+ .schemas = {schema},
59+ .current_schema_id = 1 ,
60+ .default_spec_id = 0 ,
61+ .last_partition_id = 0 ,
62+ .properties = {{" key" , " value" }},
63+ .current_snapshot_id = 3051729675574597004 ,
64+ .snapshots = {std::make_shared<Snapshot>(Snapshot{
65+ .snapshot_id = 3051729675574597004 ,
66+ .sequence_number = 0 ,
67+ .timestamp_ms = TimePointMsFromUnixMs (1515100955770 ).value (),
68+ .manifest_list = " s3://a/b/1.avro" ,
69+ .summary = {{" operation" , " append" }},
70+ })},
71+ .default_sort_order_id = 0 ,
72+ .next_row_id = 0 };
73+ return metadata;
74+ }
75+
4776 std::shared_ptr<iceberg::FileIO> io_;
4877 std::string temp_filepath_;
4978};
5079
5180TEST_F (MetadataIOTest, ReadWriteMetadata) {
52- std::vector<SchemaField> schema_fields;
53- schema_fields.emplace_back (/* field_id=*/ 1 , " x" , std::make_shared<LongType>(),
54- /* optional=*/ false );
55- auto schema = std::make_shared<Schema>(std::move (schema_fields), /* schema_id=*/ 1 );
56-
57- TableMetadata metadata{.format_version = 1 ,
58- .table_uuid = " 1234567890" ,
59- .location = " s3://bucket/path" ,
60- .last_sequence_number = 0 ,
61- .schemas = {schema},
62- .current_schema_id = 1 ,
63- .default_spec_id = 0 ,
64- .last_partition_id = 0 ,
65- .properties = {{" key" , " value" }},
66- .current_snapshot_id = 3051729675574597004 ,
67- .snapshots = {std::make_shared<Snapshot>(Snapshot{
68- .snapshot_id = 3051729675574597004 ,
69- .sequence_number = 0 ,
70- .timestamp_ms = TimePointMsFromUnixMs (1515100955770 ).value (),
71- .manifest_list = " s3://a/b/1.avro" ,
72- .summary = {{" operation" , " append" }},
73- })},
74- .default_sort_order_id = 0 ,
75- .next_row_id = 0 };
81+ TableMetadata metadata = PrepareMetadata ();
7682
7783 EXPECT_THAT (TableMetadataUtil::Write (*io_, temp_filepath_, metadata), IsOk ());
7884
@@ -84,30 +90,7 @@ TEST_F(MetadataIOTest, ReadWriteMetadata) {
8490}
8591
8692TEST_F (MetadataIOTest, ReadWriteCompressedMetadata) {
87- std::vector<SchemaField> schema_fields;
88- schema_fields.emplace_back (/* field_id=*/ 1 , " x" , std::make_shared<LongType>(),
89- /* optional=*/ false );
90- auto schema = std::make_shared<Schema>(std::move (schema_fields), /* schema_id=*/ 1 );
91-
92- TableMetadata metadata{.format_version = 1 ,
93- .table_uuid = " 1234567890" ,
94- .location = " s3://bucket/path" ,
95- .last_sequence_number = 0 ,
96- .schemas = {schema},
97- .current_schema_id = 1 ,
98- .default_spec_id = 0 ,
99- .last_partition_id = 0 ,
100- .properties = {{" key" , " value" }},
101- .current_snapshot_id = 3051729675574597004 ,
102- .snapshots = {std::make_shared<Snapshot>(Snapshot{
103- .snapshot_id = 3051729675574597004 ,
104- .sequence_number = 0 ,
105- .timestamp_ms = TimePointMsFromUnixMs (1515100955770 ).value (),
106- .manifest_list = " s3://a/b/1.avro" ,
107- .summary = {{" operation" , " append" }},
108- })},
109- .default_sort_order_id = 0 ,
110- .next_row_id = 0 };
93+ TableMetadata metadata = PrepareMetadata ();
11194
11295 auto json = ToJson (metadata);
11396 auto ret = ToJsonString (json);
0 commit comments