[SPARK-41631][SQL] Support implicit lateral column alias resolution on Aggregate#39040
Closed
anchovYu wants to merge 37 commits into
Closed
[SPARK-41631][SQL] Support implicit lateral column alias resolution on Aggregate#39040anchovYu wants to merge 37 commits into
anchovYu wants to merge 37 commits into
Conversation
(cherry picked from commit 313b2c9)
Contributor
Author
|
I will shortly address the left todos in this PR. |
beliefer
pushed a commit
to beliefer/spark
that referenced
this pull request
Dec 18, 2022
…s into one file ### What changes were proposed in this pull request? Move the two rules `WrapLateralColumnAliasReference` and `ResolveLateralColumnAliasReference` into one file `ResolveLateralColumnAlias.scala`, instead of one rule in `Analyzer.scala` and the other one in another file. Also update the code comments. ### Why are the changes needed? Found this issue during reviewing apache#39040 This refactor should make the code easier to read and review. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing UT Closes apache#39054 from gengliangwang/refactorLCA. Authored-by: Gengliang Wang <gengliang@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
| // perform an early check on current Aggregate before any lift-up / push-down to throw | ||
| // the same exception such as non-aggregate expressions not in group by, which becomes | ||
| // missing input after transformation | ||
| earlyCheckAggregate(agg) |
Member
There was a problem hiding this comment.
This seems from checkAnalysis. Could you refactor and reduce duplicated code?
Contributor
Author
There was a problem hiding this comment.
Yes, actually simplified from checkAnalysis. If this solution works and all tests pass, I can move this method to Aggregate or AnalysisHelper object.
|
|
||
| test("Non-aggregating expressions not in group by still throws the same error") { | ||
| // query without lateral alias | ||
| assert( |
cloud-fan
reviewed
Dec 20, 2022
| } | ||
| } | ||
|
|
||
| object Analyzer extends Logging { |
Contributor
There was a problem hiding this comment.
This is even more change than reverting #39054 ...
cloud-fan
reviewed
Dec 20, 2022
Contributor
Author
|
Is that a Github issue that I can re-request review from only one person? Every time I requested a second reviewer it automatically remove the request from the first reviewer.. But anyway cc @gengliangwang and @cloud-fan to review this PR. |
cloud-fan
approved these changes
Dec 21, 2022
Contributor
|
thanks, merging to master! |
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.
What changes were proposed in this pull request?
This PR implements the implicit lateral column alias on
Aggregatecase. For example,The high level implementation idea is to insert the
Projectnode above, and falling back to the resolution of lateral alias of Project code path in the last PR.LateralColumnAliasReferenceAggregateoperator is resolved, it goes through the whole aggregation list, extracts the aggregation expressions and grouping expressions to keep them in thisAggregatenode, and add aProjectabove with the original output. It doesn't do anything onLateralColumnAliasReference, but completely leave it to the Project in the future turns of this rule.Example:
Similar as the last PR (#38776), because lateral column alias has higher resolution priority than outer reference, it will try to resolve an
OuterReferenceusing lateral column alias, similar as anUnresolvedAttribute. If success, it stripsOuterReferenceand also wraps it withLateralColumnAliasReference.Why are the changes needed?
Similar as stated in #38776.
Does this PR introduce any user-facing change?
Yes, as shown in the above example, it will be able to resolve lateral column alias in Aggregate.
How was this patch tested?
Existing tests and newly added tests.