peter-toth commented on code in PR #13128:
URL: https://github.com/apache/datafusion/pull/13128#discussion_r1818015688
##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -835,40 +835,38 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for
Simplifier<'a, S> {
left,
op: Or,
right,
- }) if expr_contains(&left, &right, Or) => Transformed::yes(*left),
+ }) if expr_contains(&left, &right, Or)? => Transformed::yes(*left),
// A OR (..A..) --> (..A..)
Expr::BinaryExpr(BinaryExpr {
left,
op: Or,
right,
- }) if expr_contains(&right, &left, Or) => Transformed::yes(*right),
+ }) if expr_contains(&right, &left, Or)? =>
Transformed::yes(*right),
// A OR (A AND B) --> A
Expr::BinaryExpr(BinaryExpr {
left,
op: Or,
right,
- }) if is_op_with(And, &right, &left) => Transformed::yes(*left),
+ }) if is_op_with(And, &right, &left)? => Transformed::yes(*left),
// (A AND B) OR A --> A
Expr::BinaryExpr(BinaryExpr {
left,
op: Or,
right,
- }) if is_op_with(And, &left, &right) => Transformed::yes(*right),
+ }) if is_op_with(And, &left, &right)? => Transformed::yes(*right),
// Eliminate common factors in conjunctions e.g
// (A AND B) OR (A AND C) -> A AND (B OR C)
Expr::BinaryExpr(BinaryExpr {
left,
op: Or,
right,
- }) if has_common_conjunction(&left, &right) => {
+ }) if has_common_conjunction(&left, &right)? => {
Review Comment:
This doesn't seem correct. It is ok to just check the presence of common
non-volatile expressions in `has_common_conjunction()` to trigger
simplification, but you need to deal with volatile expressions during
simplification too and don't extract them as common.
E.g. can you please add a test like `column1 = 2 AND random() = 0 OR column1
= 2 AND random() = 0`?
--
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]