kumarUjjawal commented on code in PR #23615:
URL: https://github.com/apache/datafusion/pull/23615#discussion_r3901112241


##########
datafusion/optimizer/src/simplify_expressions/utils.rs:
##########
@@ -26,13 +27,18 @@ use datafusion_expr::{
 
 /// returns true if `needle` is found in a chain of search_op
 /// expressions. Such as: (A AND B) AND C
+///
+/// Equality uses [`NormalizeEq`] so commutative operands (`A = B` vs `B = A`)
+/// are recognized as the same predicate even when the canonicalizer is
+/// disabled, notably for `LogicalPlan::Join` filters (see
+/// <https://github.com/apache/datafusion/pull/8780>).
 fn expr_contains_inner(expr: &Expr, needle: &Expr, search_op: Operator) -> 
bool {
     match expr {
         Expr::BinaryExpr(BinaryExpr { left, op, right }) if *op == search_op 
=> {
             expr_contains_inner(left, needle, search_op)
                 || expr_contains_inner(right, needle, search_op)
         }
-        _ => expr == needle,
+        _ => expr.normalize_eq(needle),

Review Comment:
   Calling normalize_eq directly here is unsafe for WindowFunction: its 
implementation zips partition_by and order_by without checking their lengths. 
For example, predicates using the same window function with PARTITION BY a and 
PARTITION BY a, b can compare equal, allowing AND/OR simplification to silently 
discard one. CSE pairs normalize_eq with a hash check. Please add both missing 
length checks with a regression, or constrain this helper to the intended 
commutative equivalence.
   



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