Github user holdenk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9419#discussion_r43682141
  
    --- 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}
    +        }.flatten.distinct
    +
    +        val alias4AttrInAggregatedFuncAndGroupBy = new ArrayBuffer[Alias]()
    --- End diff --
    
    It seems we already know the initial size of this so lets at try and use 
that to reduce allocations.


---
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]

Reply via email to