HuaHuaY commented on code in PR #50160:
URL: https://github.com/apache/arrow/pull/50160#discussion_r3412147846
##########
cpp/src/parquet/arrow/arrow_reader_writer_test.cc:
##########
@@ -3324,6 +3325,75 @@ TEST(ArrowReadWrite, LargeList) {
}
}
+TEST(ArrowReadWrite, ListView) {
+ auto values = ArrayFromJSON(::arrow::int32(), "[1, 2, 3, 4, 5]");
+ auto offsets = ArrayFromJSON(::arrow::int32(), "[3, 0, 5, 1]");
+ auto sizes = ArrayFromJSON(::arrow::int32(), "[2, 1, 0, 2]");
+ ASSERT_OK_AND_ASSIGN(auto array, ::arrow::ListViewArray::FromArrays(
+ ::arrow::list_view(::arrow::int32()),
*offsets,
+ *sizes, *values,
default_memory_pool()));
+ auto table = Table::Make(
+ ::arrow::schema({::arrow::field("root", array->type(), false)}),
{array});
+
+ auto props_store_schema =
ArrowWriterProperties::Builder().store_schema()->build();
+ CheckSimpleRoundtrip(table, 2, props_store_schema);
+
+ ASSERT_OK_AND_ASSIGN(auto expected_array,
+ ::arrow::ListArray::FromListView(*array,
default_memory_pool()));
+ auto expected = Table::Make(
+ ::arrow::schema({::arrow::field("root", ::arrow::list(::arrow::int32()),
false)}),
+ {expected_array});
+ CheckConfiguredRoundtrip(table, expected);
+}
+
+TEST(ArrowReadWrite, EmptyListView) {
+ auto type = ::arrow::list_view(::arrow::int32());
+ auto array = ArrayFromJSON(type, "[]");
+ auto table = Table::Make(::arrow::schema({::arrow::field("root", type)}),
{array});
+
+ auto props_store_schema =
ArrowWriterProperties::Builder().store_schema()->build();
+ std::shared_ptr<Table> result;
+ ASSERT_NO_FATAL_FAILURE(
+ DoRoundtrip(table, 1, &result, default_writer_properties(),
props_store_schema));
+ ASSERT_OK(result->ValidateFull());
+
+ ASSERT_EQ(1, result->column(0)->num_chunks());
+ const auto& list_view =
+ checked_cast<const
::arrow::ListViewArray&>(*result->column(0)->chunk(0));
+ ASSERT_EQ(0, list_view.length());
+ ASSERT_NE(nullptr, list_view.value_offsets());
+ ASSERT_EQ(0, list_view.value_offsets()->size());
+ ASSERT_NE(nullptr, list_view.value_sizes());
+ ASSERT_EQ(0, list_view.value_sizes()->size());
+}
+
+TEST(ArrowReadWrite, LargeListView) {
+ auto values = ArrayFromJSON(::arrow::int32(), "[1, 2, 3, 4, 5]");
Review Comment:
I think there's not much duplicate code, so it's acceptable for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]