Revert D96106074#27373
Closed
shelton408 wants to merge 1 commit intoprestodb:release-0.297-edge19from
Closed
Conversation
Summary: This reverts the following PR GitHub Pull Request: prestodb#27199 Differential Revision: D97181706
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR reverts a previous change that allowed SELECT output aliases to be referenced from HAVING, restoring the prior semantics where HAVING cannot reference output column aliases and simplifying the OrderByExpressionRewriter back to ORDER BY–only behavior. Sequence diagram for HAVING clause analysis without SELECT alias rewritingsequenceDiagram
participant SA as StatementAnalyzer
participant QS as QuerySpecification
participant EA as ExpressionAnalyzer
participant AN as Analysis
SA->>QS: getHaving()
alt HAVING present
QS-->>SA: Optional with predicate
SA->>EA: analyzeExpression(predicate, scope)
EA-->>SA: ExpressionAnalysis
SA->>AN: recordSubqueries(QS, ExpressionAnalysis)
SA->>EA: getType(predicate)
EA-->>SA: Type predicateType
alt predicateType not BOOLEAN or UNKNOWN
SA->>SA: Throw SemanticException TYPE_MISMATCH
else predicateType valid
SA->>AN: setHaving(QS, predicate)
end
SA->>SA: visitQuerySpecification builds sourceExpressions
SA->>QS: getHaving()
QS-->>SA: Optional with predicate
SA->>SA: sourceExpressions.add(predicate)
SA->>SA: analyzeGroupingOperations(node, sourceExpressions, orderByExpressions)
SA->>SA: analyzeAggregations(node, sourceExpressions, orderByExpressions)
else HAVING absent
QS-->>SA: Optional.empty
SA->>SA: Analyze without HAVING
end
Class diagram for StatementAnalyzer HAVING and ORDER BY alias handlingclassDiagram
class StatementAnalyzer {
+Scope visitQuerySpecification(QuerySpecification node, Optional~Scope~ scope)
-void analyzeHaving(QuerySpecification node, Scope scope)
}
class OrderByExpressionRewriter {
-Multimap~QualifiedName, Expression~ assignments
+OrderByExpressionRewriter(Multimap~QualifiedName, Expression~ assignments)
+Expression rewriteIdentifier(Identifier reference, Void context, ExpressionTreeRewriter~Void~ treeRewriter)
}
class Analysis {
+void setOrderByExpressions(QuerySpecification node, List~Expression~ orderByExpressions)
+void setHaving(QuerySpecification node, Expression predicate)
+Expression getHaving(QuerySpecification node)
+void recordSubqueries(Node node, ExpressionAnalysis expressionAnalysis)
}
class QuerySpecification {
+Optional~Expression~ getHaving()
+Select getSelect()
}
class ExpressionAnalysis {
+Type getType(Expression expression)
+Collection~FunctionCall~ getWindowFunctions()
}
class SemanticException {
}
class ExpressionTreeRewriter~T~ {
}
StatementAnalyzer --> Analysis : uses
StatementAnalyzer --> QuerySpecification : analyzes
StatementAnalyzer --> ExpressionAnalysis : obtains
StatementAnalyzer --> OrderByExpressionRewriter : previously used for HAVING
OrderByExpressionRewriter --> SemanticException : throws on ambiguous alias
ExpressionAnalysis --> SemanticException : used in type checks
%% Highlight behavior change
%% HAVING now analyzed as original predicate, not via OrderByExpressionRewriter
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This reverts the following PR
GitHub Pull Request: #27199
Differential Revision: D97181706
Description
Motivation and Context
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
If release note is NOT required, use:
Summary by Sourcery
Revert support for referencing SELECT aliases in HAVING clauses and restore previous semantic analysis behavior.
Enhancements:
Tests: