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

   ### Describe the bug
   
   identified by codex, some edge cases we hit when the struct arraydata offset 
is nonzero
   
   ### To Reproduce
   
   ```rust
   #[test]
   fn test_struct_validation_accounts_for_parent_offset() {
       let data_type =
           DataType::Struct(Fields::from(vec![Field::new("x", DataType::Int32, 
false)]));
       let child = ArrayData::builder(DataType::Int32)
           .len(5)
           .add_buffer(Buffer::from_slice_ref([0, 1, 2, 3, 4]))
           .build()
           .unwrap();
   
       // The parent needs child elements 1..6, but the child only has five.
       let result = ArrayData::builder(data_type)
           .len(5)
           .offset(1)
           .add_child_data(child)
           .build();
   
       assert!(result.is_err());
   }
   ```
   
   - this should error since offset is cumulative (parent + child), so 1 + 5 -> 
beyond bounds of child
   
   ```rust
   #[test]
   fn test_struct_equal_with_parent_offset() {
       let data_type =
           DataType::Struct(Fields::from(vec![Field::new("x", DataType::Int32, 
false)]));
   
       let child1 = ArrayData::builder(DataType::Int32)
           .len(5)
           .add_buffer(Buffer::from_slice_ref([0, 1, 2, 3, 4]))
           .build()
           .unwrap();
       let child2 = child1.slice(1, 4);
   
       // data1 has offset at parent level
       // data2 has offset at child level
       let data1 = ArrayData::builder(data_type.clone())
           .len(4)
           .offset(1)
           .add_child_data(child1)
           .build()
           .unwrap();
       let data2 = ArrayData::builder(data_type)
           .len(4)
           .add_child_data(child2)
           .build()
           .unwrap();
   
       assert_eq!(data1, data2);
   }
   ```
   
   - equality needs to consider parent offset when comparing
   
   ```rust
   #[test]
   fn test_extend_struct_with_parent_offset() {
       let data_type =
           DataType::Struct(Fields::from(vec![Field::new("x", DataType::Int32, 
false)]));
       let child = ArrayData::builder(DataType::Int32)
           .len(5)
           .add_buffer(Buffer::from_slice_ref([0, 1, 2, 3, 4]))
           .build()
           .unwrap();
   
       let data = ArrayData::builder(data_type)
           .len(4)
           .offset(1)
           .add_child_data(child)
           .build()
           .unwrap();
   
       let mut mutable = MutableArrayData::new(vec![&data], false, data.len());
       mutable.try_extend(0, 0, data.len()).unwrap();
       let output = mutable.freeze();
   
       assert_eq!(output.child_data()[0].buffer::<i32>(0), &[1, 2, 3, 4]);
   }
   ```
   
   - when using mutablearraydata try_extend, it should consider the parent 
offset
   
   ### Expected behavior
   
   all of these are failing on main, they should succeed
   
   ### Additional context
   
   related to recent PR:
   
   - https://github.com/apache/arrow-rs/pull/10835
   
   (not introduced by it, just to be clear)


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