diff options
author | Liang-Chi Hsieh <viirya@appier.com> | 2015-09-15 13:33:32 -0700 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2015-09-15 13:33:32 -0700 |
commit | 841972e22c653ba58e9a65433fed203ff288f13a (patch) | |
tree | 4db2834035c81d3f45334b6a597b8ea190415602 /sql/core | |
parent | b42059d2efdf3322334694205a6d951bcc291644 (diff) | |
download | spark-841972e22c653ba58e9a65433fed203ff288f13a.tar.gz spark-841972e22c653ba58e9a65433fed203ff288f13a.tar.bz2 spark-841972e22c653ba58e9a65433fed203ff288f13a.zip |
[SPARK-10437] [SQL] Support aggregation expressions in Order By
JIRA: https://issues.apache.org/jira/browse/SPARK-10437
If an expression in `SortOrder` is a resolved one, such as `count(1)`, the corresponding rule in `Analyzer` to make it work in order by will not be applied.
Author: Liang-Chi Hsieh <viirya@appier.com>
Closes #8599 from viirya/orderby-agg.
Diffstat (limited to 'sql/core')
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala index 962b100b53..f9981356f3 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala @@ -1562,6 +1562,26 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { |ORDER BY sum(b) + 1 """.stripMargin), Row("4", 3) :: Row("1", 7) :: Row("3", 11) :: Row("2", 15) :: Nil) + + checkAnswer( + sql( + """ + |SELECT count(*) + |FROM orderByData + |GROUP BY a + |ORDER BY count(*) + """.stripMargin), + Row(2) :: Row(2) :: Row(2) :: Row(2) :: Nil) + + checkAnswer( + sql( + """ + |SELECT a + |FROM orderByData + |GROUP BY a + |ORDER BY a, count(*), sum(b) + """.stripMargin), + Row("1") :: Row("2") :: Row("3") :: Row("4") :: Nil) } test("SPARK-7952: fix the equality check between boolean and numeric types") { |