Rich-T-kid commented on code in PR #12154:
URL: https://github.com/apache/arrow-rs/pull/12154#discussion_r4557071216
##########
arrow-string/src/like.rs:
##########
@@ -282,6 +305,111 @@ fn like_op(op: Op, lhs: &dyn Datum, rhs: &dyn Datum) ->
Result<BooleanArray, Arr
}
}
+/// Rewrites run-end encoded operands into encodings that [`like_op`] already
supports,
+/// so value types, nulls and errors behave as they do without run-end
encoding.
+fn run_end_encoded_op(
+ op: Op,
+ lhs: &dyn Datum,
+ rhs: &dyn Datum,
+) -> Result<BooleanArray, ArrowError> {
+ let (left, left_is_scalar) = lhs.get();
+ let (right, right_is_scalar) = rhs.get();
+ let left_is_ree = left.as_any_ree_opt().is_some();
+ let right_is_ree = right.as_any_ree_opt().is_some();
+ if left_is_ree && left_is_scalar {
+ // A scalar's only logical value is its only physical value.
+ like_op(op, &Scalar::new(run_values(left)), rhs)
+ } else if right_is_ree && right_is_scalar {
+ like_op(op, lhs, &Scalar::new(run_values(right)))
+ } else if right_is_scalar {
+ // Against a scalar every row of a run has the same result, so match
each
+ // run once and repeat its result.
+ Ok(expand_runs(left, &like_op(op, &run_values(left), rhs)?))
+ } else if left_is_scalar {
+ Ok(expand_runs(right, &like_op(op, lhs, &run_values(right))?))
+ } else if left.is_empty() {
Review Comment:
This returns `Ok([])` before validating the underlying types. For example,
`like` between an empty REE string array and an empty `Int32Array` succeeds,
while the flat equivalent errors. Could we preserve type validation here and
add a mismatched empty-input test?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]