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
[CALCITE-3367] Add AntiJoinRule to convert project-filter-join-aggreg… #1469
Conversation
…ate into anti-join (Jin Xing)
I don't like the idea of |
I'm +1 on this idea, we may need some refactoring for the RelDecorrelator. |
We should definitely keep I agree that we could have a direct path from IN/EXISTS to semi- or anti-semi Join. As long as it doesn't add too much code. (If it adds code, that code will probably be wrong at first, because IN/EXISTS are very complicated, and will definitely need maintaining.) |
I agree that people may still write queries with direct SEMI/ANIT join, but what the |
Julian, the rule you are talking about is a rule that transforms a SEMI/ANTI join into a join on top of aggregate, which is indeed needed if we want to do join reordering (in case inner rel is larger). However I don't think we have that rule. |
I am talking about the current rule, which transforms Ideally it would also match The other direction is also valid, but as you say, we don't have that rule. |
If there is a uniqueness constraint, what is the value of transforming into a semijoin? I don't think there is any benefit. |
Semi-join may have a lower cost implementation than a regular Join. It’s worth knowing that you have one. Also, because it projects fewer columns, it may match materialized views that an equivalent ordinary join would not. Lastly, if your plan is using a semi-join operator you can safely weaken its input constraint from must-be-unique to should-be-unique. |
It is indeed true, inner/outer join in Calcite must output all the input columns instead of some. |
@julianhyde @hsyuan @danny0405
I think this idea makes a lot of sense. It is more straightforward to transform IN/EXIST to SEMI/ANTI Join when decorrelation. But SemiJoinRule also provides a way to optimize |
And my question is that if |
The |
Thanks @hsyuan
I filed a JIRA and propose to provide a direct path from IN/EXISTS to semi-join or anti-join during decorrelation. Please check when you have time |
…ate into anti-join
This PR proposes to add AntiJoinRule to convert project-filter-join-aggregate into anti-join.
The idea is from SemiJoinRule.
This issue was found when I resolve CALCITE-3363 in #1466
I failed to construct an anti-join operator from SQL string.