Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ groupingElement
: ROLLUP LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN
| CUBE LEFT_PAREN (expression (COMMA expression)*)? RIGHT_PAREN
| GROUPING SETS LEFT_PAREN groupingSet (COMMA groupingSet)* RIGHT_PAREN
| expression (COMMA expression)*
| expression (COMMA expression)* (WITH ROLLUP)?
;

groupingSet
Expand Down
29 changes: 29 additions & 0 deletions regression-test/data/nereids_syntax_p0/grouping_sets.out
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,35 @@
13 0
7 0

-- !select_with_rollup1 --
\N \N 36
2 \N 6
2 0 \N
2 1 6
3 \N 12
3 2 12
4 \N 18
4 0 \N
4 3 18

-- !select_with_rollup2 --
\N 1
2 0
3 0
4 0

-- !select_with_rollup3 --
3 0
8 0
9 0
20 1

-- !select_with_rollup4 --
\N 1
2 0
3 0
4 0

-- !select --
\N \N 36
\N 0 \N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ suite("test_nereids_grouping_sets") {
order_qt_select "select sum(k2+1), grouping_id(k1+1) from groupingSetsTable group by grouping sets((k1+1)) having (k1+1) > 1;";
order_qt_select "select sum(k2+1), grouping_id(k1+1) from groupingSetsTable group by grouping sets((k1+1), (k1)) having (k1+1) > 1;";

// with rollup
qt_select_with_rollup1 """
select (k1 + 1) k1_, k2, sum(k3) from groupingSetsTable group by
k1_, k2 with rollup order by k1_, k2
"""
qt_select_with_rollup2 "select k1+1, grouping(k1+1) from groupingSetsTable group by (k1+1) with rollup order by k1+1;";
qt_select_with_rollup3 "select sum(k2), grouping(k1+1) from groupingSetsTable group by k1+1 with rollup order by sum(k2)"
qt_select_with_rollup4 "select k1+1, grouping_id(k1) from groupingSetsTable group by k1 with rollup order by k1+1;"

// old grouping sets
qt_select """
SELECT k1, k2, SUM(k3) FROM groupingSetsTable
Expand Down