File tree 2 files changed +56
-6
lines changed
2 files changed +56
-6
lines changed Original file line number Diff line number Diff line change @@ -1671,6 +1671,13 @@ impl Parser {
1671
1671
let mut groupby = self . construct_node ( NodeType :: XXXByExprs ) ?;
1672
1672
self . next_token ( ) ?; // GROUP -> BY
1673
1673
groupby. push_node ( "by" , self . construct_node ( NodeType :: Keyword ) ?) ;
1674
+ if self . get_token ( 1 ) ?. in_ ( & vec ! [ "ROLLUP" , "CUBE" ] ) {
1675
+ self . next_token ( ) ?; // -> ROLLUP | CUBE
1676
+ groupby. push_node_vec ( "how" , self . parse_n_keywords ( 1 ) ?) ;
1677
+ } else if self . get_token ( 1 ) ?. in_ ( & vec ! [ "GROUPING" ] ) {
1678
+ self . next_token ( ) ?; // -> GROUPING
1679
+ groupby. push_node_vec ( "how" , self . parse_n_keywords ( 2 ) ?) ;
1680
+ }
1674
1681
self . next_token ( ) ?; // BY -> expr
1675
1682
groupby. push_node_vec ( "exprs" , self . parse_exprs ( & vec ! [ ] , false ) ?) ;
1676
1683
node. push_node ( "groupby" , groupby) ;
Original file line number Diff line number Diff line change @@ -2062,7 +2062,6 @@ groupby:
2062
2062
" ,
2063
2063
0 ,
2064
2064
) ) ,
2065
- // NOTE ROLLUP is not a function but it is OK
2066
2065
Box :: new( SuccessTestCase :: new(
2067
2066
"\
2068
2067
SELECT x, SUM(y) FROM t GROUP BY ROLLUP(x)
@@ -2089,13 +2088,57 @@ groupby:
2089
2088
by:
2090
2089
self: BY (Keyword)
2091
2090
exprs:
2092
- - self: ( (CallingFunction)
2093
- args:
2094
- - self: x (Identifier)
2095
- func:
2096
- self: ROLLUP (Identifier)
2091
+ - self: ( (GroupedExpr)
2092
+ expr:
2093
+ self: x (Identifier)
2094
+ rparen:
2095
+ self: ) (Symbol)
2096
+ how:
2097
+ - self: ROLLUP (Keyword)
2098
+ " ,
2099
+ 0 ,
2100
+ ) ) ,
2101
+ // CUBE() may be not a function but it's OK
2102
+ Box :: new( SuccessTestCase :: new(
2103
+ "\
2104
+ SELECT count(*) FROM t GROUP BY GROUPING SETS (a, CUBE(b))
2105
+ " ,
2106
+ "\
2107
+ self: SELECT (SelectStatement)
2108
+ exprs:
2109
+ - self: ( (CallingFunction)
2110
+ args:
2111
+ - self: * (Asterisk)
2112
+ func:
2113
+ self: count (Identifier)
2114
+ rparen:
2115
+ self: ) (Symbol)
2116
+ from:
2117
+ self: FROM (KeywordWithExpr)
2118
+ expr:
2119
+ self: t (Identifier)
2120
+ groupby:
2121
+ self: GROUP (XXXByExprs)
2122
+ by:
2123
+ self: BY (Keyword)
2124
+ exprs:
2125
+ - self: ( (StructLiteral)
2126
+ exprs:
2127
+ - self: a (Identifier)
2128
+ comma:
2129
+ self: , (Symbol)
2130
+ - self: ( (CallingFunction)
2131
+ args:
2132
+ - self: b (Identifier)
2133
+ func:
2134
+ self: CUBE (Identifier)
2135
+ rparen:
2136
+ self: ) (Symbol)
2097
2137
rparen:
2098
2138
self: ) (Symbol)
2139
+ how:
2140
+ - self: GROUPING (Keyword)
2141
+ - self: SETS (Keyword)
2099
2142
" ,
2100
2143
0 ,
2101
2144
) ) ,
You can’t perform that action at this time.
0 commit comments