Tpt commented on code in PR #27902:
URL: https://github.com/apache/datafusion/pull/27902#discussion_r4758390218
##########
datafusion/functions-nested/src/planner.rs:
##########
@@ -65,33 +70,21 @@ impl ExprPlanner for NestedFunctionPlanner {
} else if left_list_ndims < right_list_ndims {
return Ok(PlannerResult::Planned(array_prepend(left, right)));
}
- } else if matches!(op, BinaryOperator::AtArrow |
BinaryOperator::ArrowAt) {
+ } else if matches!(op, BinaryOperator::AtArrow |
BinaryOperator::ArrowAt)
+ || op == OVERLAP
+ {
let left_type = left.get_type(schema)?;
let right_type = right.get_type(schema)?;
- let left_list_ndims = list_ndims(&left_type);
- let right_list_ndims = list_ndims(&right_type);
// if both are list
- if left_list_ndims > 0 && right_list_ndims > 0 {
- if op == BinaryOperator::AtArrow {
+ if list_ndims(&left_type) > 0 && list_ndims(&right_type) > 0 {
+ return Ok(PlannerResult::Planned(match op {
// array1 @> array2 -> array_has_all(array1, array2)
- return Ok(PlannerResult::Planned(array_has_all(left,
right)));
- } else {
+ BinaryOperator::AtArrow => array_has_all(left, right),
// array1 <@ array2 -> array_has_all(array2, array1)
- return Ok(PlannerResult::Planned(array_has_all(right,
left)));
- }
- }
- }
-
- // `Operator` has no overlap variant, so `&&` only reaches this
planner via sqlparser
- #[cfg(feature = "sql")]
- if op == BinaryOperator::PGOverlap {
- let left_type = left.get_type(schema)?;
- let right_type = right.get_type(schema)?;
- if list_ndims(&left_type) > 0 && list_ndims(&right_type) > 0 {
- // array1 && array2 -> array_has_any(array1, array2)
- return
Ok(PlannerResult::Planned(crate::array_has::array_has_any(
- left, right,
- )));
+ BinaryOperator::ArrowAt => array_has_all(right, left),
+ // array1 && array2 -> array_has_any(array1, array2)
+ _ => array_has_any(left, right),
+ }));
}
}
Review Comment:
Thank you for the review! Sadly there is a cfg hidden behind the `OPERATOR`
constant that would make a bit tricky to use a match operator without
duplicating arms
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]