[C++] ArrayData support for child_data slice.
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Slice child_data
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>{a};
auto arr = std::make_shared(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++
Contributor guide
Assessment
This issue has not been assessed yet.