This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-11637-6b8df9cd27a6b65a8027c83cf73c37a1015ae0c8 in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit 78f334d9e1682770732f100f23313c91c23fc465 Author: Chang Yong Lik <[email protected]> AuthorDate: Sat Oct 17 06:54:30 2026 +0000 fix(arrow-select): keep row count in take for zero-width FixedSizeBinary (#11637) # Which issue does this PR close? - Closes #11584. # Rationale for this change `take` on a `FixedSizeBinaryArray` of width 0 returned an empty array instead of one row per index (unless an index or value was null), because `FixedSizeBinaryArray::try_new` cannot infer the length from an empty values buffer. # What changes are included in this PR? `take_fixed_size_binary` builds the result with `try_new_with_len(..., indices.len())`, like #10914 did for zero-sized `FixedSizeList`. # Are these changes tested? Yes, `test_take_zero_sized_fixed_size_binary`, next to `test_take_zero_sized_fixed_size_list`. It fails without the fix. # Are there any significant user-facing changes? No. AI use: I used Claude Code to find the cause and write the fix and test. I reviewed the change and checked that the test fails without the fix. --- arrow-select/src/take.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arrow-select/src/take.rs b/arrow-select/src/take.rs index 38d7945700..e4e5f534bf 100644 --- a/arrow-select/src/take.rs +++ b/arrow-select/src/take.rs @@ -1334,7 +1334,7 @@ fn take_fixed_size_binary<IndexType: ArrowPrimitiveType, const VALIDATE_INDICES: let value_nulls = take_nulls::<_, VALIDATE_INDICES>(values.nulls(), indices); let final_nulls = NullBuffer::union(value_nulls.as_ref(), indices.nulls()); - return FixedSizeBinaryArray::try_new(size, result_buffer, final_nulls); + return FixedSizeBinaryArray::try_new_with_len(size, result_buffer, final_nulls, indices.len()); /// Implementation of the take kernel for fixed size binary arrays. #[inline(never)] @@ -4188,4 +4188,16 @@ mod tests { assert_eq!(result.len(), 2); } + + #[test] + fn test_take_zero_sized_fixed_size_binary() { + let input = + FixedSizeBinaryArray::try_new_with_len(0, Buffer::from(Vec::<u8>::new()), None, 3) + .unwrap(); + + let indices = UInt32Array::from(vec![2, 0]); + let result = take(&input, &indices, None).unwrap(); + + assert_eq!(result.len(), 2); + } }
