Skip to content

Commit bfb85de

Browse files
committed
fix the fix
1 parent ba2f0c7 commit bfb85de

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PullOutGroupingExpressions.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,17 @@ object PullOutGroupingExpressions extends Rule[LogicalPlan] {
4949
plan transform {
5050
case a: Aggregate if a.resolved =>
5151
val complexGroupingExpressionMap = mutable.LinkedHashMap.empty[Expression, NamedExpression]
52-
val newGroupingExpressions = a.groupingExpressions
53-
.filterNot(AggregateExpression.containsAggregate)
54-
.map {
55-
case e if !e.foldable && e.children.nonEmpty =>
56-
complexGroupingExpressionMap
57-
.getOrElseUpdate(e.canonicalized, Alias(e, s"_groupingexpression")())
58-
.toAttribute
59-
case o => o
60-
}
52+
val newGroupingExpressions = a.groupingExpressions.map {
53+
case e if !e.foldable && e.children.nonEmpty =>
54+
complexGroupingExpressionMap
55+
.getOrElseUpdate(e.canonicalized, Alias(e, s"_groupingexpression")())
56+
.toAttribute
57+
case o => o
58+
}
6159
if (complexGroupingExpressionMap.nonEmpty) {
6260
def replaceComplexGroupingExpressions(e: Expression): Expression = {
6361
e match {
62+
case _ if AggregateExpression.isAggregate(e) => e
6463
case _ if e.foldable => e
6564
case _ if complexGroupingExpressionMap.contains(e.canonicalized) =>
6665
complexGroupingExpressionMap.get(e.canonicalized).map(_.toAttribute).getOrElse(e)

0 commit comments

Comments
 (0)