@@ -42,6 +42,46 @@ class ManifestListReaderTest : public TempFileTestBase {
4242 file_io_ = std::make_shared<iceberg::arrow::ArrowFileSystemFileIO>(local_fs_);
4343 }
4444
45+ std::vector<ManifestFile> PrepareTestManifestList () {
46+ std::vector<ManifestFile> manifest_files;
47+ std::string test_dir_prefix = " /tmp/db/db/iceberg_test/metadata/" ;
48+ std::vector<std::string> paths = {" 2bccd69e-d642-4816-bba0-261cd9bd0d93-m0.avro" ,
49+ " 9b6ffacd-ef10-4abf-a89c-01c733696796-m0.avro" ,
50+ " 2541e6b5-4923-4bd5-886d-72c6f7228400-m0.avro" ,
51+ " 3118c801-d2e0-4df6-8c7a-7d4eaade32f8-m0.avro" };
52+ std::vector<int64_t > file_size = {7433 , 7431 , 7433 , 7431 };
53+ std::vector<int64_t > snapshot_id = {7412193043800610213 , 5485972788975780755 ,
54+ 1679468743751242972 , 1579605567338877265 };
55+ std::vector<std::vector<uint8_t >> bounds = {{' x' , ' ;' , 0x07 , 0x00 },
56+ {' (' , 0x19 , 0x07 , 0x00 },
57+ {0xd0 , 0xd4 , 0x06 , 0x00 },
58+ {0xb8 , 0xd4 , 0x06 , 0x00 }};
59+ for (int i = 0 ; i < 4 ; ++i) {
60+ ManifestFile manifest_file;
61+ manifest_file.manifest_path = test_dir_prefix + paths[i];
62+ manifest_file.manifest_length = file_size[i];
63+ manifest_file.partition_spec_id = 0 ;
64+ manifest_file.content = ManifestFile::Content::kData ;
65+ manifest_file.sequence_number = 4 - i;
66+ manifest_file.min_sequence_number = 4 - i;
67+ manifest_file.added_snapshot_id = snapshot_id[i];
68+ manifest_file.added_files_count = 1 ;
69+ manifest_file.existing_files_count = 0 ;
70+ manifest_file.deleted_files_count = 0 ;
71+ manifest_file.added_rows_count = 1 ;
72+ manifest_file.existing_rows_count = 0 ;
73+ manifest_file.deleted_rows_count = 0 ;
74+ PartitionFieldSummary partition;
75+ partition.contains_null = false ;
76+ partition.contains_nan = false ;
77+ partition.lower_bound = bounds[i];
78+ partition.upper_bound = bounds[i];
79+ manifest_file.partitions .emplace_back (partition);
80+ manifest_files.emplace_back (manifest_file);
81+ }
82+ return manifest_files;
83+ }
84+
4585 std::shared_ptr<::arrow::fs::LocalFileSystem> local_fs_;
4686 std::shared_ptr<FileIO> file_io_;
4787};
@@ -55,74 +95,9 @@ TEST_F(ManifestListReaderTest, BasicTest) {
5595 auto read_result = manifest_reader->Files ();
5696 ASSERT_EQ (read_result.has_value (), true );
5797 ASSERT_EQ (read_result.value ().size (), 4 );
58- std::string test_dir_prefix = " /tmp/db/db/iceberg_test/metadata/" ;
59- for (const auto & file : read_result.value ()) {
60- auto manifest_path = file.manifest_path .substr (test_dir_prefix.size ());
61- if (manifest_path == " 2bccd69e-d642-4816-bba0-261cd9bd0d93-m0.avro" ) {
62- ASSERT_EQ (file.added_snapshot_id , 7412193043800610213 );
63- ASSERT_EQ (file.manifest_length , 7433 );
64- ASSERT_EQ (file.sequence_number , 4 );
65- ASSERT_EQ (file.min_sequence_number , 4 );
66- ASSERT_EQ (file.partitions .size (), 1 );
67- const auto & partition = file.partitions [0 ];
68- ASSERT_EQ (partition.contains_null , false );
69- ASSERT_EQ (partition.contains_nan .value (), false );
70- ASSERT_EQ (partition.lower_bound .value (),
71- std::vector<uint8_t >({' x' , ' ;' , 0x07 , 0x00 }));
72- ASSERT_EQ (partition.upper_bound .value (),
73- std::vector<uint8_t >({' x' , ' ;' , 0x07 , 0x00 }));
74- } else if (manifest_path == " 9b6ffacd-ef10-4abf-a89c-01c733696796-m0.avro" ) {
75- ASSERT_EQ (file.added_snapshot_id , 5485972788975780755 );
76- ASSERT_EQ (file.manifest_length , 7431 );
77- ASSERT_EQ (file.sequence_number , 3 );
78- ASSERT_EQ (file.min_sequence_number , 3 );
79- ASSERT_EQ (file.partitions .size (), 1 );
80- const auto & partition = file.partitions [0 ];
81- ASSERT_EQ (partition.contains_null , false );
82- ASSERT_EQ (partition.contains_nan .value (), false );
83- ASSERT_EQ (partition.lower_bound .value (),
84- std::vector<uint8_t >({' (' , 0x19 , 0x07 , 0x00 }));
85- ASSERT_EQ (partition.upper_bound .value (),
86- std::vector<uint8_t >({' (' , 0x19 , 0x07 , 0x00 }));
87- } else if (manifest_path == " 2541e6b5-4923-4bd5-886d-72c6f7228400-m0.avro" ) {
88- ASSERT_EQ (file.added_snapshot_id , 1679468743751242972 );
89- ASSERT_EQ (file.manifest_length , 7433 );
90- ASSERT_EQ (file.sequence_number , 2 );
91- ASSERT_EQ (file.min_sequence_number , 2 );
92- ASSERT_EQ (file.partitions .size (), 1 );
93- const auto & partition = file.partitions [0 ];
94- ASSERT_EQ (partition.contains_null , false );
95- ASSERT_EQ (partition.contains_nan .value (), false );
96- ASSERT_EQ (partition.lower_bound .value (),
97- std::vector<uint8_t >({0xd0 , 0xd4 , 0x06 , 0x00 }));
98- ASSERT_EQ (partition.upper_bound .value (),
99- std::vector<uint8_t >({0xd0 , 0xd4 , 0x06 , 0x00 }));
100- } else if (manifest_path == " 3118c801-d2e0-4df6-8c7a-7d4eaade32f8-m0.avro" ) {
101- ASSERT_EQ (file.added_snapshot_id , 1579605567338877265 );
102- ASSERT_EQ (file.manifest_length , 7431 );
103- ASSERT_EQ (file.sequence_number , 1 );
104- ASSERT_EQ (file.min_sequence_number , 1 );
105- ASSERT_EQ (file.partitions .size (), 1 );
106- const auto & partition = file.partitions [0 ];
107- ASSERT_EQ (partition.contains_null , false );
108- ASSERT_EQ (partition.contains_nan .value (), false );
109- ASSERT_EQ (partition.lower_bound .value (),
110- std::vector<uint8_t >({0xb8 , 0xd4 , 0x06 , 0x00 }));
111- ASSERT_EQ (partition.upper_bound .value (),
112- std::vector<uint8_t >({0xb8 , 0xd4 , 0x06 , 0x00 }));
113- } else {
114- ASSERT_TRUE (false ) << " Unexpected manifest file: " << manifest_path;
115- }
116- ASSERT_EQ (file.partition_spec_id , 0 );
117- ASSERT_EQ (file.content , ManifestFile::Content::kData );
118- ASSERT_EQ (file.added_files_count , 1 );
119- ASSERT_EQ (file.existing_files_count , 0 );
120- ASSERT_EQ (file.deleted_files_count , 0 );
121- ASSERT_EQ (file.added_rows_count , 1 );
122- ASSERT_EQ (file.existing_rows_count , 0 );
123- ASSERT_EQ (file.deleted_rows_count , 0 );
124- ASSERT_EQ (file.key_metadata .empty (), true );
125- }
98+
99+ auto expected_manifest_list = PrepareTestManifestList ();
100+ ASSERT_EQ (read_result.value (), expected_manifest_list);
126101}
127102
128103} // namespace iceberg
0 commit comments