spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davies <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12706] [SQL] grouping() and grouping_id...
Date Wed, 10 Feb 2016 06:32:59 GMT
Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10677#discussion_r52419520
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
    @@ -233,14 +233,39 @@ class Analyzer(
               }
             }.toMap
     
    -        val aggregations: Seq[NamedExpression] = x.aggregations.map {
    -          // If an expression is an aggregate (contains a AggregateExpression) then we
dont change
    -          // it so that the aggregation is computed on the unmodified value of its argument
    -          // expressions.
    -          case expr if expr.find(_.isInstanceOf[AggregateExpression]).nonEmpty =>
expr
    -          // If not then its a grouping expression and we need to use the modified (with
nulls from
    -          // Expand) value of the expression.
    -          case expr => expr.transformDown {
    +        val aggregations: Seq[NamedExpression] = x.aggregations.map { case expr =>
    +          // collect all the found AggregateExpression, so we can check an expression
is part of
    +          // any AggregateExpression or not.
    +          val aggsBuffer = ArrayBuffer[Expression]()
    +          def isPartOfAggregation(e: Expression): Boolean = {
    +            aggsBuffer.exists(a => a.find(_ eq e).isDefined)
    +          }
    +          expr.transformDown {
    +            // AggregateExpression should be computed on the unmodified value of its
argument
    +            // expressions, so we should not replace any references to grouping expression
    +            // inside it.
    +            case e: AggregateExpression =>
    +              aggsBuffer += e
    +              e
    +            case e if isPartOfAggregation(e) => e
    +            case e: GroupingID =>
    --- End diff --
    
    Had capture this in CheckAnasys.


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

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


Mime
View raw message