@@ -82,6 +82,108 @@ class ManifestListReaderTest : public TempFileTestBase {
8282 return manifest_files;
8383 }
8484
85+ std::vector<ManifestFile> PrepareTestManifestListPartition () {
86+ std::vector<ManifestFile> manifest_files;
87+ std::string test_dir_prefix = " iceberg-warehouse/db/v1_partition_test/metadata/" ;
88+ std::vector<std::string> paths = {" eafd2972-f58e-4185-9237-6378f564787e-m1.avro" ,
89+ " eafd2972-f58e-4185-9237-6378f564787e-m0.avro" };
90+ std::vector<int64_t > file_size = {6185 , 6113 };
91+ std::vector<int64_t > snapshot_id = {7532614258660258098 , 7532614258660258098 };
92+
93+ std::vector<std::vector<std::uint8_t >> lower_bounds = {{0x32 , 0x30 , 0x32 , 0x32 , 0x2D , 0x30 , 0x32 , 0x2D , 0x32 , 0x32 },
94+ {0x32 , 0x30 , 0x32 , 0x32 , 0x2D , 0x32 , 0x2D , 0x32 , 0x32 }};
95+
96+ std::vector<std::vector<std::uint8_t >> upper_bounds = {{0x32 , 0x30 , 0x32 , 0x32 , 0x2D , 0x32 , 0x2D , 0x32 , 0x33 },
97+ {0x32 , 0x30 , 0x32 , 0x32 , 0x2D , 0x32 , 0x2D , 0x32 , 0x33 }};
98+
99+
100+ for (int i = 0 ; i < 2 ; ++i) {
101+ ManifestFile manifest_file;
102+ manifest_file.manifest_path = test_dir_prefix + paths[i];
103+ manifest_file.manifest_length = file_size[i];
104+ manifest_file.partition_spec_id = 0 ;
105+ manifest_file.added_snapshot_id = snapshot_id[i];
106+ manifest_file.added_files_count = 4 * (1 - i);
107+ manifest_file.existing_files_count = 0 ;
108+ manifest_file.deleted_files_count = 2 * i;
109+ manifest_file.added_rows_count = 6 * (1 - i);
110+ manifest_file.existing_rows_count = 0 ;
111+ manifest_file.deleted_rows_count = 6 * i;
112+
113+ PartitionFieldSummary partition;
114+ partition.contains_null = false ;
115+ partition.contains_nan = false ;
116+ partition.lower_bound = lower_bounds[i];
117+ partition.upper_bound = upper_bounds[i];
118+ manifest_file.partitions .emplace_back (partition);
119+ manifest_files.emplace_back (manifest_file);
120+ }
121+ return manifest_files;
122+ }
123+
124+ std::vector<ManifestFile> PrepareTestManifestListComplexType () {
125+ std::vector<ManifestFile> manifest_files;
126+ std::string test_dir_prefix = " iceberg-warehouse/db/v1_type_test/metadata/" ;
127+ std::vector<std::string> paths = {" aeffe099-3bac-4011-bc17-5875210d8dc0-m1.avro" ,
128+ " aeffe099-3bac-4011-bc17-5875210d8dc0-m0.avro" };
129+ std::vector<int64_t > file_size = {6498 , 6513 };
130+ std::vector<int64_t > snapshot_id = {4134160420377642835 , 4134160420377642835 };
131+
132+ for (int i = 0 ; i < 2 ; ++i) {
133+ ManifestFile manifest_file;
134+ manifest_file.manifest_path = test_dir_prefix + paths[i];
135+ manifest_file.manifest_length = file_size[i];
136+ manifest_file.partition_spec_id = 0 ;
137+ manifest_file.added_snapshot_id = snapshot_id[i];
138+ manifest_file.added_files_count = 1 - i;
139+ manifest_file.existing_files_count = 0 ;
140+ manifest_file.deleted_files_count = i;
141+ manifest_file.added_rows_count = 2 * (1 - i);
142+ manifest_file.existing_rows_count = 0 ;
143+ manifest_file.deleted_rows_count = 3 * i;
144+ manifest_files.emplace_back (manifest_file);
145+ }
146+ return manifest_files;
147+ }
148+
149+ std::vector<ManifestFile> PrepareTestManifestListPartition2 () {
150+ std::vector<ManifestFile> manifest_files;
151+ std::string test_dir_prefix = " iceberg-warehouse/db2/v1_complex_partition_test/metadata/" ;
152+ std::vector<std::string> paths = {" 5d690750-8fb4-4cd1-8ae7-85c7b39abe14-m0.avro" ,
153+ " 5d690750-8fb4-4cd1-8ae7-85c7b39abe14-m1.avro" };
154+ std::vector<int64_t > file_size = {6402 , 6318 };
155+ std::vector<int64_t > snapshot_id = {7522296285847100621 , 7522296285847100621 };
156+ std::vector<std::vector<std::uint8_t >> lower_bounds = {{' \u0002 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' },
157+ {' \u0005 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' }};
158+ std::vector<std::vector<std::uint8_t >> upper_bounds = {{' \u0002 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' },
159+ {' \u0004 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' , ' \u0000 ' }};
160+
161+ for (int i = 0 ; i < 2 ; ++i) {
162+ ManifestFile manifest_file;
163+ manifest_file.manifest_path = test_dir_prefix + paths[i];
164+ manifest_file.manifest_length = file_size[i];
165+ manifest_file.partition_spec_id = 0 ;
166+ manifest_file.added_snapshot_id = snapshot_id[i];
167+ manifest_file.added_files_count = 0 ;
168+ manifest_file.existing_files_count = i == 0 ? 3 : 1 ;
169+ manifest_file.deleted_files_count = 1 ;
170+ manifest_file.added_rows_count = 0 ;
171+ manifest_file.existing_rows_count = i == 0 ? 4 : 1 ;
172+ manifest_file.deleted_rows_count = i == 0 ? 2 : 1 ;
173+
174+ PartitionFieldSummary partition;
175+ partition.contains_null = false ;
176+ partition.contains_nan = false ;
177+ partition.lower_bound = lower_bounds[i];
178+ partition.upper_bound = upper_bounds[i];
179+ manifest_file.partitions .emplace_back (partition);
180+ manifest_files.emplace_back (manifest_file);
181+ }
182+ return manifest_files;
183+ }
184+
185+
186+
85187 std::shared_ptr<::arrow::fs::LocalFileSystem> local_fs_;
86188 std::shared_ptr<FileIO> file_io_;
87189};
@@ -100,4 +202,43 @@ TEST_F(ManifestListReaderTest, BasicTest) {
100202 ASSERT_EQ (read_result.value (), expected_manifest_list);
101203}
102204
205+ TEST_F (ManifestListReaderTest, PartitionTest) {
206+ std::string path = GetResourcePath (
207+ " snap-7532614258660258098-1-eafd2972-f58e-4185-9237-6378f564787e.avro" );
208+ auto manifest_reader_result = ManifestListReader::MakeReader (path, file_io_);
209+ ASSERT_EQ (manifest_reader_result.has_value (), true );
210+ auto manifest_reader = std::move (manifest_reader_result.value ());
211+ auto read_result = manifest_reader->Files ();
212+ ASSERT_EQ (read_result.has_value (), true );
213+ ASSERT_EQ (read_result.value ().size (), 2 );
214+
215+ auto expected_manifest_list = PrepareTestManifestListPartition ();
216+ ASSERT_EQ (read_result.value (), expected_manifest_list);
217+ }
218+
219+ TEST_F (ManifestListReaderTest, ComplexTypeTest) {
220+ std::string path = GetResourcePath (
221+ " snap-4134160420377642835-1-aeffe099-3bac-4011-bc17-5875210d8dc0.avro" );
222+ auto manifest_reader_result = ManifestListReader::MakeReader (path, file_io_);
223+ ASSERT_EQ (manifest_reader_result.has_value (), true );
224+ auto manifest_reader = std::move (manifest_reader_result.value ());
225+ auto read_result = manifest_reader->Files ();
226+ ASSERT_EQ (read_result.has_value (), true );
227+ ASSERT_EQ (read_result.value ().size (), 2 );
228+
229+ auto expected_manifest_list = PrepareTestManifestListComplexType ();
230+ ASSERT_EQ (read_result.value (), expected_manifest_list);
231+ }
232+
233+ TEST_F (ManifestListReaderTest, PartitionTest2) {
234+ std::string path = GetResourcePath (
235+ " snap-7522296285847100621-1-5d690750-8fb4-4cd1-8ae7-85c7b39abe14.avro" );
236+ auto manifest_reader_result = ManifestListReader::MakeReader (path, file_io_);
237+ ASSERT_EQ (manifest_reader_result.has_value (), true );
238+ auto manifest_reader = std::move (manifest_reader_result.value ());
239+ auto read_result = manifest_reader->Files ();
240+ ASSERT_EQ (read_result.has_value (), true );
241+ ASSERT_EQ (read_result.value ().size (), 2 );
242+ }
243+
103244} // namespace iceberg
0 commit comments