mbutrovich opened a new issue, #11584:
URL: https://github.com/apache/arrow-rs/issues/11584
### Describe the bug
`take` on a `FixedSizeBinaryArray` of width 0 returns an array of length 0
instead of one row per index, unless an index or a value is null. As a field of
a struct or a child of a union, the short result then fails the parent's length
checks or panics.
### To Reproduce
```rust
use arrow_array::{make_array, Array, Int32Array};
use arrow_buffer::Buffer;
use arrow_data::ArrayData;
use arrow_schema::DataType;
fn main() {
let data =
ArrayData::builder(DataType::FixedSizeBinary(0)).len(3).add_buffer(Buffer::from_vec(Vec::<u8>::new())).build().unwrap();
let values = make_array(data);
let taken = arrow_select::take::take(&values, &Int32Array::from(vec![0,
2]), None).unwrap();
println!("{}", taken.len()); // 0, expected 2
}
```
### Expected behavior
The result has one row per index, here 2.
### Additional context
`take_fixed_size_binary` builds its result with
`FixedSizeBinaryArray::try_new(size, result_buffer, final_nulls)`
([take.rs](https://github.com/apache/arrow-rs/blob/72887ed91c80002bb7ec755ce1e964bab07bebea/arrow-select/src/take.rs#L1334-L1337)).
For width 0, `try_new` takes the length from the null buffer, and uses 0 when
there is none
([fixed_size_binary_array.rs](https://github.com/apache/arrow-rs/blob/72887ed91c80002bb7ec755ce1e964bab07bebea/arrow-array/src/array/fixed_size_binary_array.rs#L192-L199)).
Passing `indices.len()` through `try_new_with_len` would avoid that.
#10914 fixed the same shape for `FixedSizeList` of size 0 under `take`, and
#10270 for the row format.
Found with property-based tests that build arrays in every physical layout
the Arrow format allows.
--
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]