-
Notifications
You must be signed in to change notification settings - Fork 1.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
fix: skip EliminateCrossJoin rule if inner join with filter is found #7529
fix: skip EliminateCrossJoin rule if inner join with filter is found #7529
Conversation
3ff466a
to
542c10d
Compare
542c10d
to
9e1fb13
Compare
9e1fb13
to
aa15cfb
Compare
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.
Thank you for the contribution @epsio-banay -- @jackwener or @liukun4515 would you have time to review this PR?
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.
Thanks @epsio-banay , good catch!
LGTM.
BTW, I'm thinking about this whole method. I think we don't need differentiate between handling equal conditions and non-equal conditions, because multi join is a Query Graph and both equal conditions and non-equal conditions are edges in Graph. But I also think this is a longer-term problem. I prepare to do this job in 1-2 weeks.
Representing the joins in a query as a JoinGraph would be very interesting. I wonder if you have an idea of where would it be done? It could be as a pass prior to the LogicalPlan:
or you could do it as part of an optimization pass, like this:
Or something else I haven't thought of :) |
Thanks @epsio-banay and @jackwener |
#7549 to trace it |
Because we just want to rearrange
Collect All Inner/Cross Join into a If you are interested in https://github.com/mysql/mysql-server/blob/trunk/sql/join_optimizer/hypergraph.h its process is
|
🤔 would a multi-join work for a query like SELECT ..
FROM A JOIN B ON (a.x=b.x)
JOIN C ON (a.y = c.y AND b.z = c.z) A join graph might look like this
Would a multi-join look like
I guess then any reordering could happen as a translation from Multi-join to binary join 🤔 |
Which issue does this PR close?
Closes #7530
Rationale for this change
Explained in issue
What changes are included in this PR?
EliminateCrossJoin optimization rule should be skipped for InnerJoin with filter, this PR fixes a bug were nested InnerJoins with filter do not cause the rule to be skipped.
Are these changes tested?
yes see
eliminate_cross_not_possible_nested_inner_join_with_filter
Are there any user-facing changes?
There are no API changes but query results might differ.