aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorHerman van Hovell <hvanhovell@questtec.nl>2015-11-08 11:06:10 -0800
committerYin Huai <yhuai@databricks.com>2015-11-08 11:06:10 -0800
commit30c8ba71a76788cbc6916bc1ba6bc8522925fc2b (patch)
tree851dbdcce7d78bbf6fd4c948dd4407642fea63cc /sql/hive
parent5c4e6d7ec9157c02494a382dfb49e7fbde3be222 (diff)
downloadspark-30c8ba71a76788cbc6916bc1ba6bc8522925fc2b.tar.gz
spark-30c8ba71a76788cbc6916bc1ba6bc8522925fc2b.tar.bz2
spark-30c8ba71a76788cbc6916bc1ba6bc8522925fc2b.zip
[SPARK-11451][SQL] Support single distinct count on multiple columns.
This PR adds support for multiple column in a single count distinct aggregate to the new aggregation path. cc yhuai Author: Herman van Hovell <hvanhovell@questtec.nl> Closes #9409 from hvanhovell/SPARK-11451.
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/AggregationQuerySuite.scala37
1 files changed, 31 insertions, 6 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/AggregationQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/AggregationQuerySuite.scala
index 7f6fe33923..ea36c132bb 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/AggregationQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/AggregationQuerySuite.scala
@@ -516,21 +516,46 @@ abstract class AggregationQuerySuite extends QueryTest with SQLTestUtils with Te
Row(3, 4, 4, 3, null) :: Nil)
}
- test("multiple distinct column sets") {
+ test("single distinct multiple columns set") {
+ checkAnswer(
+ sqlContext.sql(
+ """
+ |SELECT
+ | key,
+ | count(distinct value1, value2)
+ |FROM agg2
+ |GROUP BY key
+ """.stripMargin),
+ Row(null, 3) ::
+ Row(1, 3) ::
+ Row(2, 1) ::
+ Row(3, 0) :: Nil)
+ }
+
+ test("multiple distinct multiple columns sets") {
checkAnswer(
sqlContext.sql(
"""
|SELECT
| key,
| count(distinct value1),
- | count(distinct value2)
+ | sum(distinct value1),
+ | count(distinct value2),
+ | sum(distinct value2),
+ | count(distinct value1, value2),
+ | count(value1),
+ | sum(value1),
+ | count(value2),
+ | sum(value2),
+ | count(*),
+ | count(1)
|FROM agg2
|GROUP BY key
""".stripMargin),
- Row(null, 3, 3) ::
- Row(1, 2, 3) ::
- Row(2, 2, 1) ::
- Row(3, 0, 1) :: Nil)
+ Row(null, 3, 30, 3, 60, 3, 3, 30, 3, 60, 4, 4) ::
+ Row(1, 2, 40, 3, -10, 3, 3, 70, 3, -10, 3, 3) ::
+ Row(2, 2, 0, 1, 1, 1, 3, 1, 3, 3, 4, 4) ::
+ Row(3, 0, null, 1, 3, 0, 0, null, 1, 3, 2, 2) :: Nil)
}
test("test count") {