tustvold opened a new issue, #1824:
URL: https://github.com/apache/arrow-rs/issues/1824
**Describe the bug**
I don't know if this was a change or it has always been this way, but we
permit zero-length ListArray to have no offsets. In #1620 we explicitly decided
against enforcing a single value.
Unfortunately the logic for value_offsets, duplicated in ListArray,
StringArray, BinaryArray, etc...
```
unsafe {
std::slice::from_raw_parts(
self.value_offsets.as_ptr().add(self.data.offset()),
self.len() + 1,
)
}
```
Does not take this into account
**To Reproduce**
```
#[test]
fn test_string_array_empty_offsets() {
let data = ArrayDataBuilder::new(DataType::Utf8)
.len(0)
.add_buffer(Buffer::from([]))
.add_buffer(Buffer::from([]))
.build()
.unwrap();
let array = GenericStringArray::<i32>::from(data);
assert_eq!(array.value_offsets().len(), 0); // FAILS with 1 != 0
}
```
**Expected behavior**
Given the decision to support empty offsets, I think we should always return
an empty slice for zero length array types, so that the behaviour is consistent.
**Additional context**
Discovered whilst working on #1811, so already getting returns from that
investment :grin:
--
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]