kosiew commented on code in PR #15589:
URL: https://github.com/apache/datafusion/pull/15589#discussion_r2030907522


##########
datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs:
##########
@@ -760,6 +760,23 @@ impl<S: SimplifyInfo> TreeNodeRewriter for Simplifier<'_, 
S> {
                     None => lit_bool_null(),
                 })
             }
+            // A = A --> A IS NOT NULL OR NULL
+            // A = A --> true (if A not nullable)
+            Expr::BinaryExpr(BinaryExpr {
+                left,
+                op: Eq,
+                right,
+            }) if (left == right) & !left.is_volatile() => {
+                Transformed::yes(match !info.nullable(&right)? {
+                    true => lit(true),
+                    false => Expr::BinaryExpr(BinaryExpr {
+                        left: Box::new(Expr::IsNotNull(left)),
+                        op: Or,
+                        right: Box::new(lit_bool_null()),
+                    }),
+                })
+            }

Review Comment:
   🔐 Suggestion: Consider Using left Instead of right for nullable Check
   
   While left == right ensures equality, semantically it might be clearer to 
consistently use left for readability and convention. This avoids any reader 
confusion on whether left or right is being evaluated for nullability.
   
   



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to