berkaysynnada commented on code in PR #15462:
URL: https://github.com/apache/datafusion/pull/15462#discussion_r2033185234
##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -805,6 +811,47 @@ impl BinaryExpr {
}
}
+/// Check if it meets the short-circuit condition
+/// 1. For the `AND` operator, if the `lhs` result all are `false`
+/// 2. For the `OR` operator, if the `lhs` result all are `true`
+/// 3. Otherwise, it does not meet the short-circuit condition
+fn check_short_circuit(arg: &ColumnarValue, op: &Operator) -> bool {
Review Comment:
> but wouldn't it be better to do it this way: the optimizer rewrites
simpler expressions to the left as much as possible?
Is there a planned work to implement this? If it is so, trying first lhs
makes sense. But even if that's the case, checking the rhs values as well,
before doing the all binary computation, is a preferable option?
Let's imagine this case also (I adapt my second example such that homogenous
side is lhs)
```
[true, true, true... true] AND [xxx] => return rhs, which is [xxx]
[false, false, false... false] OR [xxx] => return rhs, which is [xxx]
```
Doesn't this brings a clear gain by short-circuiting?
--
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]