2525#include " iceberg/avro/avro_reader.h"
2626#include " iceberg/manifest_list.h"
2727#include " iceberg/manifest_reader.h"
28- #include " iceberg/schema.h"
29- #include " matchers.h"
3028#include " temp_file_test_base.h"
3129#include " test_common.h"
3230
@@ -41,7 +39,33 @@ class ManifestListReaderV1Test : public ::testing::Test {
4139 file_io_ = std::make_shared<iceberg::arrow::ArrowFileSystemFileIO>(local_fs_);
4240 }
4341
44- std::vector<ManifestFile> PrepareTestManifestList () {
42+ std::shared_ptr<::arrow::fs::LocalFileSystem> local_fs_;
43+ std::shared_ptr<FileIO> file_io_;
44+
45+ void TestManifestListReading (const std::string& resource_name,
46+ const std::vector<ManifestFile>& expected_manifest_list) {
47+ std::string path = GetResourcePath (resource_name);
48+ auto manifest_reader_result = ManifestListReader::MakeReader (path, file_io_);
49+ ASSERT_EQ (manifest_reader_result.has_value (), true );
50+
51+ auto manifest_reader = std::move (manifest_reader_result.value ());
52+ auto read_result = manifest_reader->Files ();
53+ ASSERT_EQ (read_result.has_value (), true );
54+ ASSERT_EQ (read_result.value ().size (), expected_manifest_list.size ());
55+ ASSERT_EQ (read_result.value (), expected_manifest_list);
56+ }
57+ };
58+
59+ class ManifestListReaderV2Test : public TempFileTestBase {
60+ protected:
61+ static void SetUpTestSuite () { avro::AvroReader::Register (); }
62+
63+ void SetUp () override {
64+ local_fs_ = std::make_shared<::arrow::fs::LocalFileSystem>();
65+ file_io_ = std::make_shared<iceberg::arrow::ArrowFileSystemFileIO>(local_fs_);
66+ }
67+
68+ std::vector<ManifestFile> PrepareV2PartitionedTestManifestList () {
4569 std::vector<ManifestFile> manifest_files;
4670 std::string test_dir_prefix = " /tmp/db/db/iceberg_test/metadata/" ;
4771 std::vector<std::string> paths = {" 2bccd69e-d642-4816-bba0-261cd9bd0d93-m0.avro" ,
@@ -115,6 +139,7 @@ class ManifestListReaderV1Test : public ::testing::Test {
115139 }
116140 return manifest_files;
117141 }
142+
118143 std::shared_ptr<::arrow::fs::LocalFileSystem> local_fs_;
119144 std::shared_ptr<FileIO> file_io_;
120145
@@ -287,10 +312,24 @@ TEST_F(ManifestListReaderV1Test, PartitionComplexTypeTest) {
287312 expected_manifest_list);
288313}
289314
290- TEST_F (ManifestListReaderV1Test, V2NonPartitionedTest ) {
315+ TEST_F (ManifestListReaderV2Test, V2PartitionedTest ) {
291316 std::string path = GetResourcePath (
292- " snap-251167482216575399-1-ccb6dbcb-0611-48da-be68-bd506ea63188.avro" );
317+ " snap-7412193043800610213-1-2bccd69e-d642-4816-bba0-261cd9bd0d93.avro" );
318+ auto manifest_reader_result = ManifestListReader::MakeReader (path, file_io_);
319+ ASSERT_EQ (manifest_reader_result.has_value (), true );
293320
321+ auto manifest_reader = std::move (manifest_reader_result.value ());
322+ auto read_result = manifest_reader->Files ();
323+ ASSERT_EQ (read_result.has_value (), true );
324+ ASSERT_EQ (read_result.value ().size (), 4 );
325+
326+ auto expected_manifest_list = PrepareV2PartitionedTestManifestList ();
327+ ASSERT_EQ (read_result.value (), expected_manifest_list);
328+ }
329+
330+ TEST_F (ManifestListReaderV2Test, V2NonPartitionedTest) {
331+ std::string path = GetResourcePath (
332+ " snap-251167482216575399-1-ccb6dbcb-0611-48da-be68-bd506ea63188.avro" );
294333 auto manifest_reader_result = ManifestListReader::MakeReader (path, file_io_);
295334 ASSERT_EQ (manifest_reader_result.has_value (), true );
296335
0 commit comments