Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
additional comments
  • Loading branch information
aray committed Nov 19, 2015
commit 2162b6cac8d72959f4fe57dcfbdfe13ca286a615
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,12 @@ class Analyzer(
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. We need to distinguish the real grouping expression values and those nulls added by expand. Otherwise, we generate wrong results.


val aggregations: Seq[NamedExpression] = x.aggregations.map {
// Don't transform AggregateExpressions see SPARK-11275
// 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 {
case e => groupByAliases.find(_.child.semanticEquals(e)).map(_.toAttribute).getOrElse(e)
}.asInstanceOf[NamedExpression]
Expand Down