You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Light-City (via GitHub)" <gi...@apache.org> on 2023/04/13 05:21:25 UTC

[GitHub] [arrow] Light-City opened a new issue, #35097: [C++] ArrayData support for child_data slice.

Light-City opened a new issue, #35097:
URL: https://github.com/apache/arrow/issues/35097

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   When we slice an arraydata, we do not slice the child, for example: a struct array, the test case is as follows:
   
   ```cpp
   
   TEST(StructArray, ChildSlice) {
     auto a = ArrayFromJSON(int32(), "[4, 5, 6, 7]");
     auto type = struct_({field("a", int32())});
     auto children = std::vector<std::shared_ptr<Array>>{a};
     auto arr = std::make_shared<StructArray>(type, 4, children)->data();
     auto slice_arr = arr->Slice(1, 2);
     auto actual = MakeArray(slice_arr->child_data[0]);
     AssertArraysEqual(*ArrayFromJSON(int32(), "[5, 6]"), *actual,
                       /*verbose=*/true);
   }
   ```
   
   In this case ,  we expect [5, 6], but actually [4, 5, 6, 7].
   
   
   
   ```
   [==========] Running 1 test from 1 test suite.
   [----------] Global test environment set-up.
   [----------] 1 test from StructArray
   [ RUN      ] StructArray.ChildSlice
   /code/arrow/cpp/src/arrow/testing/gtest_util.cc:134: Failure
   Failed
   
   @@ -0, +0 @@
   +4
   @@ -2, +3 @@
   +7
   Expected:
     [
       5,
       6
     ]
   Actual:
     [
       4,
       5,
       6,
       7
     ]
   [  FAILED  ] StructArray.ChildSlice (3 ms)
   ```
   
   ### Component(s)
   
   C++


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

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