Skip to content

Commit 09b3f77

Browse files
committed
aggregate in group by clause causes failure in execution
1 parent e4edc31 commit 09b3f77

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ trait CheckAnalysis {
146146
s"data type.")
147147
}
148148

149+
if (expr.isInstanceOf[AggregateExpression] || expr.isInstanceOf[AggregateFunction]) {
150+
// Aggregate function in group by clause; this fails to execute
151+
failAnalysis(s"aggregate expression ${expr.prettyString} should not " +
152+
s"appear in grouping expression.")
153+
}
154+
149155
if (!expr.deterministic) {
150156
// This is just a sanity check, our analysis rule PullOutNondeterministic should
151157
// already pull out those nondeterministic expressions and evaluate them in

0 commit comments

Comments
 (0)