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 911721c69e fix: preserve zero-width FixedSizeBinary length when
filtering (#11042)
911721c69e is described below
commit 911721c69e21a2c6921b0bdb6097ba11cc101c22
Author: RIchard Baah <[email protected]>
AuthorDate: Tue Sep 15 01:04:27 2026 -0400
fix: preserve zero-width FixedSizeBinary length when filtering (#11042)
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax.
-->
- Closes None.
# Rationale for this change
edge case that currently isnt covered
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
# What changes are included in this PR?
checks for if array is empty and has no nulls, if so set the len
outright
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
# Are these changes tested?
yes
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
If this PR claims a performance improvement, please include evidence
such as benchmark results.
-->
# Are there any user-facing changes?
no
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
---
arrow-select/src/filter.rs | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/arrow-select/src/filter.rs b/arrow-select/src/filter.rs
index 85b21df03c..0e67ad7994 100644
--- a/arrow-select/src/filter.rs
+++ b/arrow-select/src/filter.rs
@@ -1017,7 +1017,13 @@ fn filter_fixed_size_binary(
let nulls = predicate.filter_nulls(array.nulls());
- FixedSizeBinaryArray::new(array.value_length(), buffer.into(), nulls)
+ FixedSizeBinaryArray::try_new_with_len(
+ array.value_length(),
+ buffer.into(),
+ nulls,
+ predicate.count,
+ )
+ .unwrap()
}
/// `filter` implementation for dictionaries
@@ -2106,6 +2112,22 @@ mod tests {
);
}
+ #[test]
+ fn test_filter_zero_width_fixed_size_binary() {
+ // value_length=0 with no nulls: row count cannot be inferred from the
empty
+ // buffer, so filter must preserve it explicitly.
+ let array = FixedSizeBinaryArray::try_new_with_len(
+ 0,
+ Buffer::from_slice_ref(&[] as &[u8]),
+ None,
+ 3,
+ )
+ .unwrap();
+ let filter_array = BooleanArray::from(vec![true, false, true]);
+ let result = filter(&array, &filter_array).unwrap();
+ assert_eq!(result.len(), 2);
+ }
+
fn test_filter_union_array(array: UnionArray) {
let filter_array = BooleanArray::from(vec![true, false, false]);
let c = filter(&array, &filter_array).unwrap();