Skip to content

Commit 2ecf3e1

Browse files
committed
Add one more negative test
1 parent e0c57f7 commit 2ecf3e1

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

sql/core/src/test/resources/sql-tests/inputs/grouping_set.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ GROUP BY GROUPING SETS ( ( c1 ), ( c2 ) )
2626
HAVING GROUPING__ID > 1;
2727

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

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

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

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

sql/core/src/test/resources/sql-tests/results/grouping_set.sql.out

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 14
2+
-- Number of queries: 15
33

44

55
-- !query 0
@@ -73,7 +73,7 @@ NULL b 20 2
7373

7474

7575
-- !query 7
76-
SELECT grouping(c1) FROM (VALUES ('x', 'a', 10), ('y', 'b', 20)) AS t (c1, c2, c3) GROUP BY c1,c2 GROUPING SETS (c1,c2)
76+
SELECT grouping(c1) FROM (VALUES ('x', 'a', 10), ('y', 'b', 20)) AS t (c1, c2, c3) GROUP BY GROUPING SETS (c1,c2)
7777
-- !query 7 schema
7878
struct<grouping(c1):tinyint>
7979
-- !query 7 output
@@ -155,3 +155,12 @@ extraneous input 'CUBE' expecting <EOF>(line 1, pos 53)
155155
== SQL ==
156156
SELECT a, b, c, count(d) FROM grouping GROUP BY WITH CUBE
157157
-----------------------------------------------------^^^
158+
159+
160+
-- !query 14
161+
SELECT c1 FROM (values (1,2), (3,2)) t(c1, c2) GROUP BY GROUPING SETS (())
162+
-- !query 14 schema
163+
struct<>
164+
-- !query 14 output
165+
org.apache.spark.sql.AnalysisException
166+
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.;

0 commit comments

Comments
 (0)