-
- Downloads
[SPARK-17114][SQL] Fix aggregates grouped by literals with empty input
## What changes were proposed in this pull request? This PR fixes an issue with aggregates that have an empty input, and use a literals as their grouping keys. These aggregates are currently interpreted as aggregates **without** grouping keys, this triggers the ungrouped code path (which aways returns a single row). This PR fixes the `RemoveLiteralFromGroupExpressions` optimizer rule, which changes the semantics of the Aggregate by eliminating all literal grouping keys. ## How was this patch tested? Added tests to `SQLQueryTestSuite`. Author: Herman van Hovell <hvanhovell@databricks.com> Closes #15101 from hvanhovell/SPARK-17114-3.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala 9 additions, 2 deletions...a/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
- sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/AggregateOptimizeSuite.scala 9 additions, 1 deletion...spark/sql/catalyst/optimizer/AggregateOptimizeSuite.scala
- sql/core/src/test/resources/sql-tests/inputs/group-by.sql 17 additions, 0 deletionssql/core/src/test/resources/sql-tests/inputs/group-by.sql
- sql/core/src/test/resources/sql-tests/results/group-by.sql.out 51 additions, 0 deletions...ore/src/test/resources/sql-tests/results/group-by.sql.out
Please register or sign in to comment