Github user holdenk commented on a diff in the pull request:
https://github.com/apache/spark/pull/9419#discussion_r43682031
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -240,10 +240,52 @@ class Analyzer(
x.child
}
+ // We will insert another Projection if the GROUP BY keys are
contained in the
+ // aggregation. And the top operators can references those keys by
its alias.
+ // e.g. SELECT a, b, sum(a) FROM src GROUP BY a, b with rollup ==>
+ // SELECT a, b, sum(a1) FROM (SELECT a, b, a AS a1 FROM src)
GROUP BY a, b with rollup
+
+ // collect all the distinct attributes that are in both
aggregation functions and
+ // group by clauses
+ val attrInAggregatedFuncAndGroupBy = aggregation.collect {
+ case aggFunc: Alias => aggFunc.collect {
+ case a : Attribute if newGroupByExprs.contains(a) => a}
--- End diff --
Were doing a contains here on a sequence, this could maybe get a bit slow
with a large number of aggregates / grouping expressions
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]