kawadakk opened a new issue, #7647:
URL: https://github.com/apache/arrow-rs/issues/7647
**Describe the bug**
The `UnionArray::logical_nulls()` of a `slice`-d single-field dense union
array has the length of the original array, not the sliced array.
**To Reproduce**
Add the following to `arrow-array/src/array/union_array.rs`:
```rust
#[test]
fn slice_union_array_single_field() {
// Dense Union
// [1, null, 3, null, 4]
let union_array = {
let mut builder = UnionBuilder::new_dense();
builder.append::<Int32Type>("a", 1).unwrap();
builder.append_null::<Int32Type>("a").unwrap();
builder.append::<Int32Type>("a", 3).unwrap();
builder.append_null::<Int32Type>("a").unwrap();
builder.append::<Int32Type>("a", 4).unwrap();
builder.build().unwrap()
};
// [null, 3, null]
let union_slice = union_array.slice(1, 3);
let logical_nulls = union_slice.logical_nulls().unwrap();
assert_eq!(logical_nulls.len(), 3);
assert!(logical_nulls.is_null(0));
assert!(logical_nulls.is_valid(1));
assert!(logical_nulls.is_null(2));
}
```
```
---- array::union_array::tests::slice_union_array_single_field stdout ----
thread 'array::union_array::tests::slice_union_array_single_field' panicked
at arrow-array/src/array/union_array.rs:1659:9:
assertion `left == right` failed
left: 5
right: 3
```
**Expected behavior**
Not panicking
**Additional context**
<!--
Add any other context about the problem here.
-->
--
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]