-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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-6338] RelMdCollation#project can return an incomplete list of collations in the presence of aliasing #3739
Conversation
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 for looking into it
One tiny not really related to the changes comment however since this method was touch org.apache.calcite.rel.metadata.RelMdCollation#project
It seems it never returns null
, In that case should we remove @Nullable
or replace it with @NonNull
?
Quality Gate passedIssues Measures |
Thanks for the review @snuyanzin .
I tried both removing |
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.
LGTM
@snuyanzin could you please take another look at the PR? Do you have any other comment? I plan to squash & merge in the next 24-48h if no further remarks arrive. |
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.
@snuyanzin could you please take another look at the PR? Do you have any other comment? I plan to squash & merge in the next 24-48h if no further remarks arrive.
yes, feel free to go ahead it looks ok from my side
and sorry for the delay
I tried both removing @nullable and replacing it with @nonnull, but in both cases CheckFramework failed (due to the annotations used by the methods called by the modified one).
yep, I also tried that locally and failed, sorry for confusing....
…f collations in the presence of aliasing
More details in: CALCITE-6338
Note: the quidem test that required an adjustment actually shows a good example of a side effect of this bug:
Notice how the original plan contained an unnecessary EnumerableSort:
scott.EMP table scan is "by default" sorted by EMPNO ($0), for this reason there is no Sort on the first input of the MergeJoin. However, since the second input contains a Calc (this fix is for both Project and Calc) that was projecting EMPNO as $2 and $4, the planner was incorrectly assuming that we needed an EnumerableSort on $4 (i.e. the "second" EMPNO), when in fact this was not the case (the table scab on scott.EMP was already sorted by EMPNO). This was because the Project (or Calc in this case) collation calculation was [2], instead of [2][4].
Thus, the new plan seems both correct and more efficient.