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-12450-fc5a8ee45af1537dcf94689f28f552ff601cc98b in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit 2150def5615c9bb1091b3186539cc96f68ab4371 Author: Ivan Kiselev <[email protected]> AuthorDate: Wed Nov 25 02:34:41 2026 +0000 fix(arrow-ord): compare empty run-end encoded slices at a nonzero offset (#12450) # Which issue does this PR close? - Closes #12449. # Rationale for this change Comparing an empty `RunArray` slice that starts past its first run overflows in `expand_from_runs` and `ree_physical_indices`. # What changes are included in this PR? `compare_op` returns an empty result for empty inputs once types are checked. # Are these changes tested? Yes. `test_ree_mixed` now compares empty slices at a nonzero offset against a scalar and against another `RunArray`. # Are there any significant user-facing changes? No. AI assistance was used for this PR but I thoroughly reviewed this change before opening a PR. Co-authored-by: Amp <[email protected]> --- arrow-ord/src/cmp.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arrow-ord/src/cmp.rs b/arrow-ord/src/cmp.rs index 2205f54bc1..bb35fc457d 100644 --- a/arrow-ord/src/cmp.rs +++ b/arrow-ord/src/cmp.rs @@ -259,6 +259,11 @@ fn compare_op(op: Op, lhs: &dyn Datum, rhs: &dyn Datum) -> Result<BooleanArray, ))); } + // An empty run-end encoded slice reports start run 0 whatever its offset + if len == 0 { + return Ok(BooleanArray::new(BooleanBuffer::new_unset(0), None)); + } + let l_side = SideInfo { is_scalar: l_s, dict: l_v, @@ -1590,6 +1595,13 @@ mod tests { let empty_a = ree_str(&[(Some("a"), 1)]).slice(0, 0); let empty_b = ree_str(&[(Some("b"), 1)]).slice(0, 0); assert_eq!(eq(&empty_a, &empty_b).unwrap().len(), 0); + + // Empty REE sliced past the first run + let empty_a = ree_str(&[(Some("a"), 1), (Some("b"), 1)]).slice(2, 0); + let empty_b = ree_str(&[(Some("a"), 2)]).slice(2, 0); + let s = Scalar::new(StringArray::from(vec!["a"])); + assert_eq!(eq(&empty_a, &s).unwrap().len(), 0); + assert_eq!(eq(&empty_a, &empty_b).unwrap().len(), 0); } #[test]
