pitrou commented on code in PR #45008:
URL: https://github.com/apache/arrow/pull/45008#discussion_r1881977966
##########
cpp/src/arrow/stl_test.cc:
##########
@@ -245,6 +245,26 @@ TEST(TestTableFromTupleVector, ListType) {
ASSERT_TRUE(expected_table->Equals(*table));
}
+TEST(TestTableFromTupleVector, FixedSizeListType) {
Review Comment:
This adds a test for `TableFromTupleRange`, but can you also add a test for
`TupleRangeFromTable`?
##########
cpp/src/arrow/stl_test.cc:
##########
@@ -245,6 +245,26 @@ TEST(TestTableFromTupleVector, ListType) {
ASSERT_TRUE(expected_table->Equals(*table));
}
+TEST(TestTableFromTupleVector, FixedSizeListType) {
+ using tuple_type = std::tuple<std::array<int64_t, 4>>;
+
+ auto expected_schema = std::make_shared<Schema>(
+ FieldVector{field("column1", fixed_size_list(int64(), 4), false)});
+ std::shared_ptr<Array> expected_array =
+ ArrayFromJSON(fixed_size_list(int64(), 4), "[[1, 1, 2, 34], [2, -4, 1,
1]]");
+ std::shared_ptr<Table> expected_table = Table::Make(expected_schema,
{expected_array});
+ std::cout << expected_table->ToString() << std::endl;
+
+ std::vector<tuple_type> rows{tuple_type(std::array<int64_t, 4>{1, 1, 2, 34}),
+ tuple_type(std::array<int64_t, 4>{2, -4, 1,
1})};
+ std::vector<std::string> names{"column1"};
+
+ std::shared_ptr<Table> table;
+ ASSERT_OK(TableFromTupleRange(default_memory_pool(), rows, names, &table));
+
+ ASSERT_TRUE(expected_table->Equals(*table));
Review Comment:
These tests are very old, we have slightly better helpers now:
```suggestion
AssertTablesEqual(*expected_table, *table);
```
##########
cpp/src/arrow/stl_test.cc:
##########
@@ -245,6 +245,26 @@ TEST(TestTableFromTupleVector, ListType) {
ASSERT_TRUE(expected_table->Equals(*table));
}
+TEST(TestTableFromTupleVector, FixedSizeListType) {
+ using tuple_type = std::tuple<std::array<int64_t, 4>>;
+
+ auto expected_schema = std::make_shared<Schema>(
+ FieldVector{field("column1", fixed_size_list(int64(), 4), false)});
+ std::shared_ptr<Array> expected_array =
+ ArrayFromJSON(fixed_size_list(int64(), 4), "[[1, 1, 2, 34], [2, -4, 1,
1]]");
+ std::shared_ptr<Table> expected_table = Table::Make(expected_schema,
{expected_array});
+ std::cout << expected_table->ToString() << std::endl;
Review Comment:
Can you remove this? I assume you needed it to debug the test.
##########
cpp/src/arrow/stl_test.cc:
##########
@@ -245,6 +245,26 @@ TEST(TestTableFromTupleVector, ListType) {
ASSERT_TRUE(expected_table->Equals(*table));
}
+TEST(TestTableFromTupleVector, FixedSizeListType) {
+ using tuple_type = std::tuple<std::array<int64_t, 4>>;
+
+ auto expected_schema = std::make_shared<Schema>(
+ FieldVector{field("column1", fixed_size_list(int64(), 4), false)});
+ std::shared_ptr<Array> expected_array =
+ ArrayFromJSON(fixed_size_list(int64(), 4), "[[1, 1, 2, 34], [2, -4, 1,
1]]");
+ std::shared_ptr<Table> expected_table = Table::Make(expected_schema,
{expected_array});
+ std::cout << expected_table->ToString() << std::endl;
+
+ std::vector<tuple_type> rows{tuple_type(std::array<int64_t, 4>{1, 1, 2, 34}),
+ tuple_type(std::array<int64_t, 4>{2, -4, 1,
1})};
+ std::vector<std::string> names{"column1"};
+
+ std::shared_ptr<Table> table;
+ ASSERT_OK(TableFromTupleRange(default_memory_pool(), rows, names, &table));
Review Comment:
We should add validation here:
```suggestion
ASSERT_OK(table->ValidateFull());
```
--
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]