westonpace commented on code in PR #7366:
URL: https://github.com/apache/arrow-rs/pull/7366#discussion_r2026930221


##########
arrow-array/src/array/struct_array.rs:
##########
@@ -523,6 +547,55 @@ mod tests {
         assert_eq!(0, struct_array.offset());
     }
 
+    #[test]
+    fn test_struct_array_from_data_with_offset_and_length() {
+        let int_arr = Int32Array::from(vec![1, 2, 3, 4, 5]);
+        let int_field = Field::new("x", DataType::Int32, false);
+        let struct_nulls = NullBuffer::new(BooleanBuffer::from(vec![true, 
true, false]));

Review Comment:
   There's a bit of ambiguity / redundancy here.  Both `ArrayData` and 
`NullBuffer` can have an offset.  As best I can tell from the `ArrayData` code, 
it is meant to assume the offset is baked into the `NullBuffer` and the 
`ArrayData` offset does not apply to the `NullBuffer` (although I see another 
potential issue in the `validate` function, I'll open a new ticket to question 
that).
   
   However, looking at the FFI code, it does appear what you'd normally get 
is...
   
   ```
   let validity = BooleanBuffer::from(vec![true, true, true, false, true]);
   validity = validity.slice(1, 3);
   let struct_nulls = NullBuffer::new(validity);
   ```
   
   I can update the test to more accurately reflect what happens in FFI.



-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to