@@ -48,21 +48,21 @@ namespace iceberg::parquet {
4848
4949namespace {
5050
51- Status WriteTableInner (Writer& writer, std::shared_ptr<::arrow::Array> data) {
51+ Status WriteArrayInner (Writer& writer, std::shared_ptr<::arrow::Array> data) {
5252 ArrowArray arr;
5353 ICEBERG_ARROW_RETURN_NOT_OK (::arrow::ExportArray (*data, &arr));
5454 ICEBERG_RETURN_UNEXPECTED (writer.Write (arr));
5555 return writer.Close ();
5656}
5757
58- Status WriteTable (std::shared_ptr<::arrow::Array> data,
58+ Status WriteArray (std::shared_ptr<::arrow::Array> data,
5959 const WriterOptions& writer_options) {
6060 ICEBERG_ASSIGN_OR_RAISE (
6161 auto writer, WriterFactoryRegistry::Open (FileFormatType::kParquet , writer_options));
62- return WriteTableInner (*writer, data);
62+ return WriteArrayInner (*writer, data);
6363}
6464
65- Status ReadTable (std::shared_ptr<::arrow::Array>& out,
65+ Status ReadArray (std::shared_ptr<::arrow::Array>& out,
6666 const ReaderOptions& reader_options) {
6767 ICEBERG_ASSIGN_OR_RAISE (
6868 auto reader, ReaderFactoryRegistry::Open (FileFormatType::kParquet , reader_options));
@@ -74,8 +74,7 @@ Status ReadTable(std::shared_ptr<::arrow::Array>& out,
7474 }
7575 auto arrow_c_array = read_data.value ();
7676
77- ArrowSchema arrow_schema;
78- ICEBERG_RETURN_UNEXPECTED (ToArrowSchema (*reader_options.projection , &arrow_schema));
77+ ICEBERG_ASSIGN_OR_RAISE (ArrowSchema arrow_schema, reader->Schema ());
7978 ICEBERG_ARROW_ASSIGN_OR_RETURN (out,
8079 ::arrow::ImportArray (&arrow_c_array, &arrow_schema));
8180 return {};
@@ -91,9 +90,9 @@ void DoRoundtrip(std::shared_ptr<::arrow::Array> data, std::shared_ptr<Schema> s
9190 ASSERT_THAT (writer_data, IsOk ())
9291 << " Failed to create writer: " << writer_data.error ().message ;
9392 auto writer = std::move (writer_data.value ());
94- ASSERT_THAT (WriteTableInner (*writer, data), IsOk ());
93+ ASSERT_THAT (WriteArrayInner (*writer, data), IsOk ());
9594
96- ASSERT_THAT (ReadTable (out, {.path = basePath,
95+ ASSERT_THAT (ReadArray (out, {.path = basePath,
9796 .length = writer->length (),
9897 .io = file_io,
9998 .projection = schema}),
@@ -127,7 +126,7 @@ class ParquetReaderTest : public ::testing::Test {
127126 R"([[1 , " Foo" ],[2 , " Bar" ],[3 , " Baz" ]])")
128127 .ValueOrDie();
129128
130- ASSERT_TRUE (WriteTable (
129+ ASSERT_TRUE (WriteArray (
131130 array, {.path = temp_parquet_file_, .schema = schema, .io = file_io_}));
132131 }
133132
@@ -309,7 +308,7 @@ TEST_F(ParquetReadWrite, EmptyStruct) {
309308 std::shared_ptr<FileIO> file_io = arrow::ArrowFileSystemFileIO::MakeMockFileIO();
310309 const std::string basePath = " base.parquet" ;
311310
312- ASSERT_THAT (WriteTable (array, {.path = basePath, .schema = schema, .io = file_io}),
311+ ASSERT_THAT (WriteArray (array, {.path = basePath, .schema = schema, .io = file_io}),
313312 IsError (ErrorKind::kNotImplemented ));
314313}
315314
@@ -353,11 +352,12 @@ TEST_F(ParquetReadWrite, SimpleTypeRoundTrip) {
353352 ASSERT_THAT (ToArrowSchema (*schema, &arrow_c_schema), IsOk ());
354353 auto arrow_schema = ::arrow::ImportType (&arrow_c_schema).ValueOrDie ();
355354
356- auto array =
357- ::arrow::json::ArrayFromJSONString (
358- ::arrow::struct_ (arrow_schema->fields ()),
359- R"([[true , 1 , 2 , 1.1 , 1.2 , " abc" , 44614000 , 1756696503000000 ], [false , 0 , 0 , 0 , 0 , " " , 0 , 0 ], [null, null, null, null, null, null, null, null]])")
360- .ValueOrDie();
355+ auto array = ::arrow::json::ArrayFromJSONString (
356+ ::arrow::struct_ (arrow_schema->fields ()),
357+ R"([[true , 1 , 2 , 1.1 , 1.2 , " abc" , 44614000 , 1756696503000000 ],
358+ [false , 0 , 0 , 0 , 0 , " " , 0 , 0 ],
359+ [null, null, null, null, null, null, null, null]])")
360+ .ValueOrDie();
361361
362362 std::shared_ptr<::arrow::Array> out;
363363 DoRoundtrip (array, schema, out);
0 commit comments