You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/09 09:40:21 UTC

[GitHub] [arrow-rs] tustvold opened a new issue, #1824: value_offsets Returns Invalid Slice For Empty Offsets Buffer

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: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold closed issue #1824: Invalid Value Offsets Slice For Empty Variable Length Arrays

Posted by GitBox <gi...@apache.org>.
tustvold closed issue #1824: Invalid Value Offsets Slice For Empty Variable Length Arrays
URL: https://github.com/apache/arrow-rs/issues/1824


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org