-
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-6746] Optimization rule ProjectWindowTranspose is unsound #4113
Conversation
List<RexNode> analyze = new ArrayList<>(); | ||
if (group.lowerBound.getOffset() != null) { | ||
analyze.add(group.lowerBound.getOffset()); | ||
} | ||
if (group.upperBound.getOffset() != null) { | ||
analyze.add(group.upperBound.getOffset()); | ||
} | ||
referenceFinder.apply(analyze); | ||
|
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.
Why not simply:
group.lowerBound.accept(referenceFinder);
group.upperBound.accept(referenceFinder);
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.
It doesn't work, since the RexWindowBound does not derive from RexNode.
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.
RexWindowBound accepts RexVisitor. In your case, if its a bounded window bound, it should take care of visiting the offset (also offset is not nullable). See this: https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/rex/RexWindowBounds.java#L181
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 seems to work in this case.
The style of visitors I am used to requires always the entry point to be a visitor apply
function, and not an accept
function of the visited object. This is because the visitor may setup and teardown some data structures on apply
.
A quick look through the codebase shows lots of accept calls, so I will use your suggestion.
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.
Because this is such a small change I have updated my previous commit instead of creating a new one.
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
6a5780a
to
2bf0941
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.
Can you also add a 1 liner description as well? The rest LGTM.
Where should I add the description? In the change or in the test? |
Quality Gate passedIssues Measures |
The visitor that keep track of the used fields did not account for the window bounds.