Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add one more negative test
  • Loading branch information
dilipbiswal committed Jul 20, 2018
commit 2ecf3e183e51f13ec9c92692d29854f01eb327c5
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GROUP BY GROUPING SETS ( ( c1 ), ( c2 ) )
HAVING GROUPING__ID > 1;

-- Group sets without explicit group by
SELECT grouping(c1) FROM (VALUES ('x', 'a', 10), ('y', 'b', 20)) AS t (c1, c2, c3) GROUP BY c1,c2 GROUPING SETS (c1,c2);
SELECT grouping(c1) FROM (VALUES ('x', 'a', 10), ('y', 'b', 20)) AS t (c1, c2, c3) GROUP BY GROUPING SETS (c1,c2);

-- Mutiple grouping within a grouping set
SELECT -c1 AS c1 FROM (values (1,2), (3,2)) t(c1, c2) GROUP BY GROUPING SETS ((c1), (c1, c2));
Expand All @@ -49,3 +49,5 @@ SELECT a, b, c, count(d) FROM grouping GROUP BY WITH ROLLUP;

SELECT a, b, c, count(d) FROM grouping GROUP BY WITH CUBE;

SELECT c1 FROM (values (1,2), (3,2)) t(c1, c2) GROUP BY GROUPING SETS (());

13 changes: 11 additions & 2 deletions sql/core/src/test/resources/sql-tests/results/grouping_set.sql.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 14
-- Number of queries: 15


-- !query 0
Expand Down Expand Up @@ -73,7 +73,7 @@ NULL b 20 2


-- !query 7
SELECT grouping(c1) FROM (VALUES ('x', 'a', 10), ('y', 'b', 20)) AS t (c1, c2, c3) GROUP BY c1,c2 GROUPING SETS (c1,c2)
SELECT grouping(c1) FROM (VALUES ('x', 'a', 10), ('y', 'b', 20)) AS t (c1, c2, c3) GROUP BY GROUPING SETS (c1,c2)
-- !query 7 schema
struct<grouping(c1):tinyint>
-- !query 7 output
Expand Down Expand Up @@ -155,3 +155,12 @@ extraneous input 'CUBE' expecting <EOF>(line 1, pos 53)
== SQL ==
SELECT a, b, c, count(d) FROM grouping GROUP BY WITH CUBE
-----------------------------------------------------^^^


-- !query 14
SELECT c1 FROM (values (1,2), (3,2)) t(c1, c2) GROUP BY GROUPING SETS (())
-- !query 14 schema
struct<>
-- !query 14 output
org.apache.spark.sql.AnalysisException
expression '`c1`' is neither present in the group by, nor is it an aggregate function. Add to group by or wrap in first() (or first_value) if you don't care which value you get.;