peter-toth commented on code in PR #13128:
URL: https://github.com/apache/datafusion/pull/13128#discussion_r1818561682
##########
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:
That's weird and seems incorrect to me. BTW, this is what Spark does:
```
scala> sql("select * from t where column1 = 2 AND rand() = 0 OR column1 = 2
AND rand() = 0").explain(true);
== Parsed Logical Plan ==
'Project [*]
+- 'Filter ((('column1 = 2) AND ('rand() = 0)) OR (('column1 = 2) AND
('rand() = 0)))
+- 'UnresolvedRelation [t], [], false
== Analyzed Logical Plan ==
column1: int, column2: int
Project [column1#0, column2#1]
+- Filter (((column1#0 = 2) AND (rand(-1409433140814249342) = cast(0 as
double))) OR ((column1#0 = 2) AND (rand(2383542950853957003) = cast(0 as
double))))
+- SubqueryAlias spark_catalog.default.t
+- HiveTableRelation [`spark_catalog`.`default`.`t`,
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Data Cols: [column1#0,
column2#1], Partition Cols: []]
== Optimized Logical Plan ==
Filter (isnotnull(column1#0) AND ((column1#0 = 2) AND
((rand(-1409433140814249342) = 0.0) OR (rand(2383542950853957003) = 0.0))))
+- HiveTableRelation [`spark_catalog`.`default`.`t`,
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Data Cols: [column1#0,
column2#1], Partition Cols: []]
== Physical Plan ==
*(1) Filter ((isnotnull(column1#0) AND (column1#0 = 2)) AND
((rand(-1409433140814249342) = 0.0) OR (rand(2383542950853957003) = 0.0)))
+- Scan hive spark_catalog.default.t [column1#0, column2#1],
HiveTableRelation [`spark_catalog`.`default`.`t`,
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Data Cols: [column1#0,
column2#1], Partition Cols: []]
```
--
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]