JasonLi-cn commented on code in PR #13249:
URL: https://github.com/apache/datafusion/pull/13249#discussion_r1828614538


##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -1675,12 +1675,34 @@ impl<'a, S: SimplifyInfo> TreeNodeRewriter for 
Simplifier<'a, S> {
                 }
             }
 
+            // null <op> A --> null,
+            Expr::BinaryExpr(BinaryExpr {
+                left,
+                op: Eq | NotEq | Gt | GtEq | Lt | LtEq,
+                right: _,
+            }) if always_null(&left, info) => 
Transformed::yes(lit_bool_null()),
+
+            // A <op> null --> null,
+            Expr::BinaryExpr(BinaryExpr {
+                left: _,
+                op: Eq | NotEq | Gt | GtEq | Lt | LtEq,
+                right,
+            }) if always_null(&right, info) => 
Transformed::yes(lit_bool_null()),
+
             // no additional rewrites possible
             expr => Transformed::no(expr),
         })
     }
 }
 
+fn always_null<S: SimplifyInfo>(expr: &Expr, info: &S) -> bool {
+    is_null(expr)

Review Comment:
   The `is_null` function cannot contain a non-`Expr::Literal` case where data 
type is `DataType::Null`(eg. Expr::Column). Maybe we should change the name of 
`always_null`? 🤔 



-- 
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]

Reply via email to