-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Remove redundant ORDER BY from WITH and views #18159
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.
looks good.
379b963
to
7d1d87f
Compare
Be intentional about whether the analyzer is being called for a top-level statement, which does not require or expect an outer scope to exist.
The merge componenents were being planned with the scope passed in to the method, which is empty due to merge being a top-level statement. Technically, this is incorrect, as those components cannot exist without an outer scope.
7d1d87f
to
1b276af
Compare
@@ -457,23 +457,28 @@ class StatementAnalyzer | |||
|
|||
public Scope analyze(Node node) | |||
{ | |||
return analyze(node, Optional.empty()); | |||
return analyze(node, Optional.empty(), true); | |||
} | |||
|
|||
public Scope analyze(Node node, Scope outerQueryScope) |
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.
Consider getting rid of this method and making the caller explicitly say top level or not.
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.
Actually, this method implies it's not top-level (since there's an outer query scope). It's the method below that is not necessary. I'll update its usages and remove it.
Track whether the query being analyzed is at the top level to decide whether the ORDER BY is ineffective.
1b276af
to
e651e6f
Compare
Any suggestion for release note entry @martint ? Also .. does this need doc update? |
@mosabua, added it to the PR description |
ORDER BY without LIMIT / OFFSET is irrelevant unless it's in the top-level query.
Alternative to #18153
Release notes
(x) Release notes are required, with the following suggested text: