-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPING SETS #17948
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
Conversation
|
Test build #76796 has finished for PR 17948 at commit
|
|
@cloud-fan Could you check this? Thanks! |
| */ | ||
| object ResolveAggAliasInGroupBy extends Rule[LogicalPlan] { | ||
|
|
||
| // This is a strict check though, we put this to apply the rule only in alias expressions |
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.
... only if the expression is not resolvable by child
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.
ok
|
LGTM |
|
Test build #76848 has started for PR 17948 at commit |
| // This is a strict check though, we put this to apply the rule only if the expression is not | ||
| // resolvable by child. | ||
| private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = | ||
| !child.output.exists(a => resolver(a.name, attrName)) |
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.
Nit: style
private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
!child.output.exists(a => resolver(a.name, attrName))
}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.
Thanks! Fixed.
|
Test build #76849 has started for PR 17948 at commit |
|
LGTM too. : ) |
|
|
||
| case gs @ GroupingSets(selectedGroups, groups, child, aggs) | ||
| if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) && | ||
| (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) => |
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.
groups should cover selectedGroups. So we may not need to add selectedGroups here.
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.
Aha, I see. It looks reasonable. I'll update. Thanks!
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.
Are we sure that grouping expressions are all pure attributes? If not, this check might fail.
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.
Oh. nvm. It is of course.
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.
yea, thanks!
| case gs @ GroupingSets(selectedGroups, groups, child, aggs) | ||
| if conf.groupByAliases && child.resolved && aggs.forall(_.resolved) && | ||
| (selectedGroups :+ groups).exists(_.exists(_.isInstanceOf[UnresolvedAttribute])) => | ||
| def mayResolveAttrByAggregateExprs(exprs: Seq[Expression]): Seq[Expression] = exprs.map { |
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.
I think we should do exprs.map { _.transform { ... like above.
|
LGTM |
|
Test build #76855 has finished for PR 17948 at commit
|
## What changes were proposed in this pull request? This pr added `Analyzer` code for supporting aliases in CUBE/ROLLUP/GROUPING SETS (This is follow-up of #17191). ## How was this patch tested? Added tests in `SQLQueryTestSuite`. Author: Takeshi Yamamuro <[email protected]> Closes #17948 from maropu/SPARK-20710. (cherry picked from commit 92ea7fd) Signed-off-by: Wenchen Fan <[email protected]>
|
thanks, merging to master/2.2 |
## What changes were proposed in this pull request? This pr added `Analyzer` code for supporting aliases in CUBE/ROLLUP/GROUPING SETS (This is follow-up of apache#17191). ## How was this patch tested? Added tests in `SQLQueryTestSuite`. Author: Takeshi Yamamuro <[email protected]> Closes apache#17948 from maropu/SPARK-20710.
## What changes were proposed in this pull request? This pr added `Analyzer` code for supporting aliases in CUBE/ROLLUP/GROUPING SETS (This is follow-up of apache#17191). ## How was this patch tested? Added tests in `SQLQueryTestSuite`. Author: Takeshi Yamamuro <[email protected]> Closes apache#17948 from maropu/SPARK-20710.
What changes were proposed in this pull request?
This pr added
Analyzercode for supporting aliases in CUBE/ROLLUP/GROUPING SETS (This is follow-up of #17191).How was this patch tested?
Added tests in
SQLQueryTestSuite.