diff options
author | Wenchen Fan <wenchen@databricks.com> | 2017-04-20 16:59:38 +0200 |
---|---|---|
committer | Herman van Hovell <hvanhovell@databricks.com> | 2017-04-20 16:59:38 +0200 |
commit | b91873db0930c6fe885c27936e1243d5fabd03ed (patch) | |
tree | 45459b54f7e1c9b502d3e957c9fe0290a4614e06 /sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala | |
parent | c6f62c5b8106534007df31ca8c460064b89b450b (diff) | |
download | spark-b91873db0930c6fe885c27936e1243d5fabd03ed.tar.gz spark-b91873db0930c6fe885c27936e1243d5fabd03ed.tar.bz2 spark-b91873db0930c6fe885c27936e1243d5fabd03ed.zip |
[SPARK-20409][SQL] fail early if aggregate function in GROUP BY
## What changes were proposed in this pull request?
It's illegal to have aggregate function in GROUP BY, and we should fail at analysis phase, if this happens.
## How was this patch tested?
new regression test
Author: Wenchen Fan <wenchen@databricks.com>
Closes #17704 from cloud-fan/minor.
Diffstat (limited to 'sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala')
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala index e7079120bb..8569c2d76b 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameAggregateSuite.scala @@ -538,4 +538,11 @@ class DataFrameAggregateSuite extends QueryTest with SharedSQLContext { Seq(Row(3, 0, 0.0, 1, 5.0), Row(2, 1, 4.0, 0, 0.0)) ) } + + test("aggregate function in GROUP BY") { + val e = intercept[AnalysisException] { + testData.groupBy(sum($"key")).count() + } + assert(e.message.contains("aggregate functions are not allowed in GROUP BY")) + } } |