kumarUjjawal commented on code in PR #23615:
URL: https://github.com/apache/datafusion/pull/23615#discussion_r3709831639
##########
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:
expr_contains is also used by the BitwiseXor rules. With canonicalization
disabled, (a + b) ^ (b + a) now matches the XOR guard through NormalizeEq, but
delete_xor_in_complex_expr still uses structural ==, so it rebuilds the
original expression and reports a transformation. This makes the simplifier
exhaust its three-cycle limit without changing the result. Please either
restrict normalized matching to the AND/OR callers or make XOR deletion use the
same equality relation, with a no-canonicalize XOR regression.
--
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]