helgikrs opened a new issue #862:
URL: https://github.com/apache/arrow-rs/issues/862
The `value_offsets` function on a union only returns the least significant
byte for the offset of a value, producing incorrect offsets when there are more
than 256 values.
```rust
use arrow::{
array::{UnionBuilder, Int32Array},
datatypes::Int32Type,
};
fn main() {
let mut builder = UnionBuilder::new_dense(300);
let values: Vec<_> = (0..300).collect();
values.iter().for_each(|v| builder.append::<Int32Type>("a",
*v).unwrap());
let union = builder.build().unwrap();
for i in 0..300 {
assert_eq!(union.value_offset(i), i as i32);
let slot = union.value(i);
let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(slot.len(), 1);
let value = slot.value(0);
assert_eq!(i as i32, value);
}
}
```
The above code fails for the 256th value index, returning 0 instead of 256
as expected.
--
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]