Skip to content
Open
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
3 changes: 3 additions & 0 deletions sql/tsql/TSqlLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ CREATION_DISPOSITION : 'CREATION_DISPOSITION';
CREDENTIAL : 'CREDENTIAL';
CROSS : 'CROSS';
CRYPTOGRAPHIC : 'CRYPTOGRAPHIC';
CUBE : 'CUBE';
CUME_DIST : 'CUME_DIST';
CURRENT : 'CURRENT';
CURRENT_DATE : 'CURRENT_DATE';
Expand Down Expand Up @@ -857,6 +858,7 @@ RIGHT : 'RIGHT';
ROBUST : 'ROBUST';
ROLE : 'ROLE';
ROLLBACK : 'ROLLBACK';
ROLLUP : 'ROLLUP';
ROOT : 'ROOT';
ROUND_ROBIN : 'ROUND_ROBIN';
ROUTE : 'ROUTE';
Expand Down Expand Up @@ -984,6 +986,7 @@ STOP_ON_ERROR : 'STOP_ON_ERROR';
STR : 'STR';
STRING_AGG : 'STRING_AGG';
STRING_ESCAPE : 'STRING_ESCAPE';
STRING_SPLIT : 'STRING_SPLIT';
STUFF : 'STUFF';
SUBJECT : 'SUBJECT';
SUBSCRIBE : 'SUBSCRIBE';
Expand Down
18 changes: 14 additions & 4 deletions sql/tsql/TSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -4014,7 +4014,7 @@ query_specification
// https://msdn.microsoft.com/en-us/library/ms177673.aspx
(
GROUP BY (
(groupByAll = ALL? groupBys += group_by_item (',' groupBys += group_by_item)*)
(groupByAll = ALL? groupBys += group_by_item (',' groupBys += group_by_item)* (WITH (ROLLUP | CUBE))?)
| GROUPING SETS '(' groupSets += grouping_sets_item (
',' groupSets += grouping_sets_item
)* ')'
Expand Down Expand Up @@ -4080,10 +4080,18 @@ grouping_sets_item

group_by_item
: expression
/*| rollup_spec
| rollup_spec
| cube_spec
| grouping_sets_spec
| grand_total*/
;

// ROLLUP specification - can be used in modern syntax
rollup_spec
: ROLLUP '(' expression_list_? ')'
;

// CUBE specification
cube_spec
: CUBE '(' expression_list_? ')'
;

option_clause
Expand Down Expand Up @@ -4477,6 +4485,8 @@ built_in_functions
)? # STRINGAGG
// https://docs.microsoft.com/en-us/sql/t-sql/functions/string-escape-transact-sql?view=sql-server-ver16
| STRING_ESCAPE '(' text_ = expression ',' type_ = expression ')' # STRING_ESCAPE
// https://learn.microsoft.com/en-us/sql/t-sql/functions/string-split-transact-sql?view=sql-server-ver16
| STRING_SPLIT '(' string = expression ',' separator = expression (',' enable_ordinal = expression)? ')' # STRING_SPLIT
// https://msdn.microsoft.com/fr-fr/library/ms188043.aspx
| STUFF '(' str = expression ',' from = expression ',' to = expression ',' str_with = expression ')' # STUFF
// https://docs.microsoft.com/en-us/sql/t-sql/functions/substring-transact-sql?view=sql-server-ver16
Expand Down
Loading