This is an automated email from the ASF dual-hosted git repository.

Jefffrey pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new baa4bd3a3b Fix take on zero-width FixedSizeListArray (#10915)
baa4bd3a3b is described below

commit baa4bd3a3b1ff1f73e37fa14b8adc1b73273f4f4
Author: Stefan Wang <[email protected]>
AuthorDate: Sun Aug 30 03:57:04 2026 -0400

    Fix take on zero-width FixedSizeListArray (#10915)
    
    # Which issue does this PR close?
    
    - Closes https://github.com/apache/arrow-rs/issues/10914.
    
    # Rationale for this change
    
    `take` returns no rows for a non-nullable `FixedSizeListArray` whose
    list size
    is zero, regardless of how many indices were requested. With a three-row
    input
    and indices `[2, 0]`, the result has length 0 instead of 2.
    
    The take kernel rebuilt the result with `FixedSizeListArray::try_new`.
    That
    constructor cannot infer a row count from an empty child array when
    there is no
    null buffer, so it defaults to zero.
    
    # What changes are included in this PR?
    
    The kernel now passes `indices.len()` to
    `FixedSizeListArray::try_new_with_length`. For nonzero list sizes this
    is the
    same length previously derived from the child array. A regression test
    covers
    the zero-width case.
    
    # Are these changes tested?
    
    Yes.
    
    <details>
    <summary>Raw test output</summary>
    
    ```text
    $ git rev-parse HEAD
    cbbb56bba13c85f36505453b08f22f8ab71b5794
    $ cargo test -p arrow-select --test issue_10914
    test take_preserves_zero_width_fixed_size_list_length ... FAILED
    assertion `left == right` failed
      left: 0
     right: 2
    
    $ git rev-parse HEAD
    b9dac7cfd239766b5d77dfbcb18ca9524bfbeba1
    $ cargo test -p arrow-select
    test result: ok. 418 passed; 0 failed
    test result: ok. 17 passed; 0 failed
    ```
    
    </details>
    
    # Are there any user-facing changes?
    
    `take` now preserves one output row per requested index for zero-width
    `FixedSizeListArray` values. No public API changes.
    
    Signed-off-by: 1fanwang <[email protected]>
---
 arrow-select/src/take.rs | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/arrow-select/src/take.rs b/arrow-select/src/take.rs
index 454d22d3ed..2bc5c3a31a 100644
--- a/arrow-select/src/take.rs
+++ b/arrow-select/src/take.rs
@@ -863,7 +863,13 @@ fn take_fixed_size_list<IndexType: ArrowPrimitiveType, 
const CHECKED: bool>(
         take_impl::<UInt32Type, CHECKED>(child.as_ref(), &list_indices)?
     };
 
-    FixedSizeListArray::try_new(field.clone(), length as i32, taken_child, 
nulls)
+    FixedSizeListArray::try_new_with_length(
+        field.clone(),
+        length as i32,
+        taken_child,
+        nulls,
+        indices.len(),
+    )
 }
 
 #[inline(never)]
@@ -3214,4 +3220,21 @@ mod tests {
         assert_eq!(child.value(4), 1);
         assert_eq!(child.value(5), 2);
     }
+
+    #[test]
+    fn test_take_zero_sized_fixed_size_list() {
+        let input = FixedSizeListArray::try_new_with_length(
+            Field::new_list_field(DataType::Int32, true).into(),
+            0,
+            Arc::new(Int32Array::new_null(0)),
+            None,
+            3,
+        )
+        .unwrap();
+
+        let indices = UInt32Array::from(vec![2, 0]);
+        let result = take(&input, &indices, None).unwrap();
+
+        assert_eq!(result.len(), 2);
+    }
 }

Reply via email to