kylebarron opened a new issue, #6152:
URL: https://github.com/apache/arrow-rs/issues/6152

   **Describe the bug**
   
   In Python with pyarrow, we can check that an array has been sliced by 
checking its `offset`:
   
   ```py
   import pyarrow as pa
   arr = pa.array([1, 2, 3, 4])
   arr.offset
   # 0
   sliced = arr.slice(2, 2)
   sliced.offset
   # 2
   ```
   
   However it seems that in arrow-rs `offset` is hard-coded to be `0`:
   
https://github.com/apache/arrow-rs/blob/80ed7128510bac114c6feec08c34ef3beed3a44a/arrow-array/src/array/primitive_array.rs#L1112-L1114
   
   So that means this simple test fails:
   
   ```rs
   #[cfg(test)]
   mod test {
       use arrow::datatypes::Int64Type;
       use arrow_array::{Array, PrimitiveArray};
   
       #[test]
       fn test_offset() {
           let arr: PrimitiveArray<Int64Type> = PrimitiveArray::from(vec![1, 2, 
3, 4]);
           let offset = 2;
           let sliced = arr.slice(offset, 2);
           assert_eq!(sliced.offset(), offset);
       }
   }
   ```
   
   ```
   assertion `left == right` failed
     left: 0
    right: 2
   ```
   
   This seems like a bug, or am I missing something?
   
   **To Reproduce**
   
   Above test.
   
   **Expected behavior**
   
   Expected `array.offset()` to reflect the array's slice.
   
   **Additional context**
   
   This was found while researching 
https://github.com/apache/arrow-rs/issues/6151, and is somewhat related.


-- 
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]

Reply via email to