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

    https://github.com/apache/spark/pull/18779#discussion_r130613115
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -1010,7 +1014,16 @@ class Analyzer(
                     s"(valid range is [1, ${aggs.size}])")
               case o => o
             }
    -        Aggregate(newGroups, aggs, child)
    +        // If an aggregateExpression is integer, after replaced with this 
aggregateExpression, the
    +        // groupExpression will be considered as an ordinal still, so we 
should filter it.
    +        var filterGroups: Seq[Expression] = Nil
    +        newGroups.foreach { ng =>
    +          ng match {
    +            case a: Alias => if (!isIntLiteral (a.child)) filterGroups :+= 
ng
    +            case _ => filterGroups :+= ng
    +          }
    +        }
    +        Aggregate(filterGroups, aggs, child)
    --- End diff --
    
    @10110346 Please see previous comment: 
https://github.com/apache/spark/pull/18779#issuecomment-319007812
    
    The basic idea is, instead of resolve `UnresolvedOrdinal` to actual 
aggregate expressions, we resolve it to `ResolvedOrdinal`.
    
    Then in the beginning of optimization, we replace all `ResolvedOrdinal` to 
actual aggregate expressions.
    
    What do you think?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to