-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove ExpressionEquivalence #21276
Remove ExpressionEquivalence #21276
Conversation
Did you mean "TestEE" or "EE"? |
Good catch. Yes, ExpressionEquivalence and associated tests. |
@@ -764,7 +762,7 @@ public PlanNode visitSpatialJoin(SpatialJoinNode node, RewriteContext<Expression | |||
PlanNode output = node; | |||
if (leftSource != node.getLeft() || | |||
rightSource != node.getRight() || | |||
!areExpressionsEquivalent(newJoinPredicate, joinPredicate)) { | |||
!newJoinPredicate.equals(joinPredicate)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the assumption is that newJoinPredicate cannot be similar to (equivalent), but different from, joinPredicate?
what does guarantee this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a stronger requirement to detect whether the predicate was rewritten by the optimization. Before, it just checked whether they were equivalent based on some semantic-preserving transformations. Now it's based on whether they are exactly the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is, was ExpressionEquivalence
more forgiving than equals
? Maybe we keep ExpressionEquivalence
abstraction but with equals
inside?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was more lenient than equality. However, I don't think that matters in practice.
The only canonicalizations this class supports are:
AND(AND(x, y), z)
=>AND(x, y, z)
. Same forOR
.AND(x, x, x, a)
=>AND(x, a)
. Same forOR
. I believe there's a bug here, though, as it ignores non-deterministic operations that should be evaluated multiple times.a = b
=>b = a
a is distinct from b
=>b is distinct from a
All of these are already handled by the expression optimizer and canonicalizer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there's a bug here, though, as it ignores non-deterministic operations that should be evaluated multiple times.
This demonstrates the issue:
ResolvedFunction random = new TestingFunctionResolution().resolveFunction("random", fromTypes());
Expression expression = new IsNull(new Call(random, List.of()));
assertNotEquivalent(
new Logical(AND, List.of(expression, expression)),
expression);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these are already handled by the expression optimizer and canonicalizer.
the newJoinPredicate
comes thru the optimizer (PredicatePushDown.Rewriter#simplifyExpression
), does it also do canonicalization?
LGTM, but i don't think I know why/when it became obsolete. @sopel39 do you want to take a look? |
This abstraction doesn't appear to be needed anymore.
The optimizer performs many of the canonicalizations that this class was doing. I wasn't able to find any queries that produce different plans with or without this code. |
This abstraction doesn't appear to be needed anymore.
Fixes #21235
Release notes
(x) Release notes are required, with the following suggested text: