[CALCITE-7405] Pre-process expressions for correlations before building projection in SqlToRelConverter#4779
Conversation
xuzifu666
left a comment
There was a problem hiding this comment.
Need to fix CI error first.
| /.vscode/* | ||
|
|
||
| # IDEA | ||
| /out |
There was a problem hiding this comment.
When I run with intellij, git detected a ton of extra files.
3784f65 to
5314e24
Compare
|
|
If we create a temporary |
Thats not an unreasonable suggestion, however I expect that change would also create a lot of test changes, both in this project and anything downstream. |
|
I prefer a simpler, more intuitive processing logic, even if it affects some of the original plans. As you mentioned, are there other places where similar issues arise, and would it be better to have a unified logic for handling them? |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@calcite.apache.org list. Thank you for your contributions. |
|
I'm hoping to get more reviews on this.
Thats fine, but I imagine that solution will take significant amount of time and effort (which I do not have for this project), and my preference (as I imagine is the preference of many others) is that we solve this severe bug we know about sooner, rather than wait for a better approach to correlation in (at a minimum) SqlToRelConverter. |
@ian-bertolacci Hello, are you still working on this project? I can take some time to review it. Do you want to continue? |
|
Yes I would like it to be reviewed. |
| /.vscode/* | ||
|
|
||
| # IDEA | ||
| /out |
There was a problem hiding this comment.
.gitignore changes should be in a separate PR
| } | ||
|
|
||
| List<RexNode> newExprs = new ArrayList<>(exprs); | ||
| Consumer<RelNode> callback = (RelNode r) -> { }; |
There was a problem hiding this comment.
The callback first assigns a null operation, which is then overridden within the if block. If someone later inserts code between the two assignments and uses the callback again, the incorrect (null operation) version will be used.
There was a problem hiding this comment.
I'll make this final and assign the no-op in an else block.
| /** Wrapper around optionally returned results from {@link #massageExpressionsForCorrelation}. */ | ||
| private static class MassagedCorrelationExpressions { | ||
| /** Modified expressions. */ | ||
| public final List<RexNode> exprs; |
101efb2 to
9a044af
Compare
|
Changes made and commit rebased to current main head |
9a044af to
06fb75b
Compare
|
Where do we stand on this? |
|
@silundong I think you are one of the most qualified to review this, if you have time |
As I mentioned before, I create a temporary This approach resolves the issue without causing any other test regressions. IMO, it's not only effective but also simpler and more intuitive. Do you see any drawbacks to it? |
|
@silundong that makes sense, and the added tests pass with your changes. I will push a commit with them. Sorry that I did not understand this when you first made this comment several months ago. |
…ng projection in SqlToRelConverter
06fb75b to
56de3f3
Compare
|



To circumvent the bloat optimizations, it is necessary to provide the correlation variables (if they exist) to the builder.
The main change here is to accomplish the logic done in
SqlToRelConverter.getCorrelationswithout having built the Project node.In this way we (a) extract the correlation id to use for the RelBuilder, and (b) normalize/resolve the correlation ids and rewrite the expressions; all before invoking the RelBuilder.
I've done my best to reuse existing logic.
SqlToRelConverter.getCorrelationsandSqlToRelConverter.massageExpressionsForCorrelationrequire a lot of the same logic for resolving the correlation variables for the current scope, so that was moved to a common utility method (SqlToRelConverter.getCorrelationInfo).