Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19488#discussion_r145292665
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
---
@@ -2677,4 +2678,29 @@ class SQLQuerySuite extends QueryTest with
SharedSQLContext {
checkAnswer(df, Row(1, 1, 1))
}
}
+
+ test("SRARK-22266: the same aggregate function was calculated multiple
times") {
+ val query = "SELECT a, max(b+1), max(b+1) + 1 FROM testData2 GROUP BY
a"
+ val df = sql(query)
+ val physical = df.queryExecution.sparkPlan
+ val aggregates = physical.collect {
+ case agg : HashAggregateExec => agg
+ }
+ aggregates.foreach { agg =>
--- End diff --
nit:
```
assert(aggregates.length == 1)
assert(aggregates.head.aggregateExpressions.size == 1)
```
If the implementation changed and we execute the query with other aggregate
implementations, we should make sure this test is not ignored.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]