You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mroz45 (via GitHub)" <gi...@apache.org> on 2024/12/12 10:19:36 UTC

[PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

mroz45 opened a new pull request, #45008:
URL: https://github.com/apache/arrow/pull/45008

   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### What changes are included in this PR?
   This PR introduces support for fixed-size lists in Apache Arrow's STL conversion.  Added specializations for arrow::stl::ConversionTraits<T> and arrow::CTypeTraits<T> to handle std::array as a fixed-size list and also Unit Test.
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ### Are these changes tested?
   Yes, new type is tested.
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ### Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
   -->
   <!-- **This PR includes breaking changes to public APIs.** -->
   
   <!--
   Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
   -->
   <!-- **This PR contains a "Critical Fix".** -->


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 commented on PR #45008:
URL: https://github.com/apache/arrow/pull/45008#issuecomment-2550922513

   The CI failure is unrelated. Merging.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #45008:
URL: https://github.com/apache/arrow/pull/45008#issuecomment-2538468228

   :warning: GitHub issue #45005 **has been automatically assigned in GitHub** to PR creator.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "mroz45 (via GitHub)" <gi...@apache.org>.
mroz45 commented on code in PR #45008:
URL: https://github.com/apache/arrow/pull/45008#discussion_r1882020420


##########
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:
   My bad. I will fix it.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 merged PR #45008:
URL: https://github.com/apache/arrow/pull/45008


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45008:
URL: https://github.com/apache/arrow/pull/45008#discussion_r1881971434


##########
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());
     ASSERT_OK(TableFromTupleRange(default_memory_pool(), rows, names, &table));
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #45008:
URL: https://github.com/apache/arrow/pull/45008#discussion_r1881970811


##########
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 line? I assume you needed it to debug the test.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #45008:
URL: https://github.com/apache/arrow/pull/45008#discussion_r1882008322


##########
cpp/src/arrow/type_traits.h:
##########
@@ -540,6 +540,15 @@ struct CTypeTraits<std::vector<CType>> : public TypeTraits<ListType> {
   }
 };
 

Review Comment:
   `/// \addtogroup` ?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "mroz45 (via GitHub)" <gi...@apache.org>.
mroz45 commented on PR #45008:
URL: https://github.com/apache/arrow/pull/45008#issuecomment-2539138719

   > Thanks for doing this @mroz45 . I think this is a good idea, can please address the following comments?
   
   Is it looking good for now? @pitrou 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "mroz45 (via GitHub)" <gi...@apache.org>.
mroz45 commented on code in PR #45008:
URL: https://github.com/apache/arrow/pull/45008#discussion_r1882029812


##########
cpp/src/arrow/stl_test.cc:
##########
@@ -245,6 +245,26 @@ TEST(TestTableFromTupleVector, ListType) {
   ASSERT_TRUE(expected_table->Equals(*table));
 }
 
+TEST(TestTableFromTupleVector, FixedSizeListType) {

Review Comment:
   I will add this test in a moment.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #45008:
URL: https://github.com/apache/arrow/pull/45008#issuecomment-2585132892

   After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 37eb3b50101aa5e32b5122e61593a1a592a22274.
   
   There were no benchmark performance regressions. 🎉
   
   The [full Conbench report](https://github.com/apache/arrow/runs/35466344696) has more details. It also includes information about 7 possible false positives for unstable benchmarks that are known to sometimes produce them.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 commented on code in PR #45008:
URL: https://github.com/apache/arrow/pull/45008#discussion_r1886221709


##########
cpp/src/arrow/stl.h:
##########
@@ -187,6 +187,34 @@ struct ConversionTraits<std::vector<ValueCType>>
   }
 };
 
+template <class CType_, std::size_t N>

Review Comment:
   The template parameter of `ConversionTraits` should be `ValueCType` instead of `CType_` (you are probably copying the style from `ARROW_STL_CONVERSION(CType_, ArrowType_)` but that is a macro parameter).



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 commented on PR #45008:
URL: https://github.com/apache/arrow/pull/45008#issuecomment-2550798843

   > LGTM. Please fix the lint (format) issue in CI. Then I'll merge it. Thanks.
   
   Never mind the format, I've rebased the PR and fixed the format issue. Let's wait for CI.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GH-45005 [C++] Support for fixed-size list in conversion of range tuple [arrow]

Posted by "pitrou (via GitHub)" <gi...@apache.org>.
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org