westonpace opened a new issue, #7595:
URL: https://github.com/apache/arrow-rs/issues/7595
**Describe the bug**
When an ArrayData representing a struct array is sliced then the new offset
is incorrectly doubled since it is both set to the struct array and it is
pushed down into child arrays.
**To Reproduce**
```
let x = Int32Array::from(vec![0, 1, 2, 3, 4, 5]);
let struct_array = StructArray::new(
Fields::from(vec![Field::new("x", DataType::Int32, true)]),
vec![Arc::new(x.clone())],
None,
)
.into_data();
let sliced = struct_array.slice(1, 4);
// Panics
let arr = make_array(sliced);
```
**Expected behavior**
There are two options. Either add the offset to the parent data's offset or
push the offset into the children. Since the `StructArray` version of slicing
does the latter (`StructArray` has no self-offset) I would recommend that
approach.
**Additional context**
This problem arose for us because we accept data from pyarrow. In pyarrow
struct slicing is done by setting the offset of the parent and not pushing it
down into the children (the opposite of the approach taken by arrow-rs). This
caused a panic when we attempted to cross the C data boundary.
--
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]