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

    https://github.com/apache/spark/pull/5134#discussion_r28200100
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -115,6 +115,25 @@ object UnionPushdown extends Rule[LogicalPlan] {
      */
     object ColumnPruning extends Rule[LogicalPlan] {
       def apply(plan: LogicalPlan): LogicalPlan = plan transform {
    +    // Eliminate unneeded attributes from Expand that is used in 
GroupingSets
    +    case a @ Aggregate(groupByExprs, aggregations, e @ Expand(projections, 
output, child))
    +        if (e.outputSet -- a.references).nonEmpty =>
    +
    +      val substitution = projections.map { groupExpr =>
    --- End diff --
    
    nit: `substitution` is usually the word we use for a map that contains 
replacements.  Perhaps `prunedProjections`?.  
    
    It would also be good to comment why it is safe to remove certain 
projections, but others must be kept around.  In particular I don't understand 
why you are collecting literals.  If understand the logic here correctly you 
are going to do transformations like the following:
    
    ```
    GroupExpression(a + 1) => GroupExpression(a, 1)
    GroupExpression(a + b) => GroupExpression(a, b)
    ```
    
    Is a `collect` really the right thing to be using here?


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