[SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPING SETS#17948
[SPARK-20710][SQL] Support aliases in CUBE/ROLLUP/GROUPING SETS#17948maropu wants to merge 4 commits intoapache:masterfrom
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.
... only if the expression is not resolvable by child
|
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.
Nit: style
private def notResolvableByChild(attrName: String, child: LogicalPlan): Boolean = {
!child.output.exists(a => resolver(a.name, attrName))
}|
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.
groups should cover selectedGroups. So we may not need to add selectedGroups here.
There was a problem hiding this comment.
Aha, I see. It looks reasonable. I'll update. Thanks!
There was a problem hiding this comment.
Are we sure that grouping expressions are all pure attributes? If not, this check might fail.
| 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.
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 <yamamuro@apache.org> Closes #17948 from maropu/SPARK-20710. (cherry picked from commit 92ea7fd) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
|
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 <yamamuro@apache.org> 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 <yamamuro@apache.org> 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.