@@ -91,7 +91,7 @@ statement
9191 )* ' )' (KW_COMMENT comment=string)? (KW_WITH properties)? # createTable
9292 | KW_DROP KW_TABLE (KW_IF KW_EXISTS )? tableRef # dropTable
9393 | KW_INSERT KW_INTO tableRef columnList? rootQuery # insertInto
94- | KW_DELETE KW_FROM tableRef (KW_WHERE booleanExpression)? # delete
94+ | KW_DELETE KW_FROM tableRef (whereClause)? # delete
9595 | KW_TRUNCATE KW_TABLE tableRef # truncateTable
9696 | KW_COMMENT KW_ON KW_TABLE tableRef KW_IS (string | KW_NULL ) # commentTable
9797 | KW_COMMENT KW_ON KW_VIEW viewRef KW_IS (string | KW_NULL ) # commentView
@@ -106,7 +106,7 @@ statement
106106 | KW_ALTER KW_TABLE tableName=tableRef KW_SET KW_PROPERTIES propertyAssignments # setTableProperties
107107 | KW_ALTER KW_TABLE tableName=tableRef KW_EXECUTE procedureName=functionName (
108108 ' (' (callArgument (' ,' callArgument)*)? ' )'
109- )? (KW_WHERE where=booleanExpression)? # tableExecute
109+ )? (whereClause)? # tableExecute
110110 | KW_ANALYZE tableRef (KW_WITH properties)? # analyze
111111 | KW_CREATE (KW_OR KW_REPLACE )? KW_MATERIALIZED KW_VIEW (KW_IF KW_NOT KW_EXISTS )? viewNameCreate (
112112 KW_GRACE KW_PERIOD interval
@@ -167,26 +167,24 @@ statement
167167 | KW_DESC tableOrViewName # showColumns
168168 | KW_SHOW KW_FUNCTIONS ((KW_FROM | KW_IN ) schemaRef)? (
169169 KW_LIKE pattern=string (KW_ESCAPE escape=string)?
170- )? # showFunctions
171- | KW_SHOW KW_SESSION (KW_LIKE pattern=string (KW_ESCAPE escape=string)?)? # showSession
172- | KW_SET KW_SESSION KW_AUTHORIZATION authorizationUser # setSessionAuthorization
173- | KW_RESET KW_SESSION KW_AUTHORIZATION # resetSessionAuthorization
174- | KW_SET KW_SESSION qualifiedName EQ expression # setSession
175- | KW_RESET KW_SESSION qualifiedName # resetSession
176- | KW_START KW_TRANSACTION (transactionMode (' ,' transactionMode)*)? # startTransaction
177- | KW_COMMIT KW_WORK ? # commit
178- | KW_ROLLBACK KW_WORK ? # rollback
179- | KW_PREPARE identifier KW_FROM statement # prepare
180- | KW_DEALLOCATE KW_PREPARE identifier # deallocate
181- | KW_EXECUTE identifier (KW_USING expression (' ,' expression)*)? # execute
182- | KW_EXECUTE KW_IMMEDIATE string (KW_USING expression (' ,' expression)*)? # executeImmediate
183- | KW_DESCRIBE KW_INPUT identifier # describeInput
184- | KW_DESCRIBE KW_OUTPUT identifier # describeOutput
185- | KW_SET KW_PATH pathSpecification # setPath
186- | KW_SET KW_TIME KW_ZONE ( KW_LOCAL | expression) # setTimeZone
187- | KW_UPDATE tableRef KW_SET updateAssignment (' ,' updateAssignment)* (
188- KW_WHERE where=booleanExpression
189- )? # update
170+ )? # showFunctions
171+ | KW_SHOW KW_SESSION (KW_LIKE pattern=string (KW_ESCAPE escape=string)?)? # showSession
172+ | KW_SET KW_SESSION KW_AUTHORIZATION authorizationUser # setSessionAuthorization
173+ | KW_RESET KW_SESSION KW_AUTHORIZATION # resetSessionAuthorization
174+ | KW_SET KW_SESSION qualifiedName EQ expression # setSession
175+ | KW_RESET KW_SESSION qualifiedName # resetSession
176+ | KW_START KW_TRANSACTION (transactionMode (' ,' transactionMode)*)? # startTransaction
177+ | KW_COMMIT KW_WORK ? # commit
178+ | KW_ROLLBACK KW_WORK ? # rollback
179+ | KW_PREPARE identifier KW_FROM statement # prepare
180+ | KW_DEALLOCATE KW_PREPARE identifier # deallocate
181+ | KW_EXECUTE identifier (KW_USING expression (' ,' expression)*)? # execute
182+ | KW_EXECUTE KW_IMMEDIATE string (KW_USING expression (' ,' expression)*)? # executeImmediate
183+ | KW_DESCRIBE KW_INPUT identifier # describeInput
184+ | KW_DESCRIBE KW_OUTPUT identifier # describeOutput
185+ | KW_SET KW_PATH pathSpecification # setPath
186+ | KW_SET KW_TIME KW_ZONE ( KW_LOCAL | expression) # setTimeZone
187+ | KW_UPDATE tableRef KW_SET updateAssignment (' ,' updateAssignment)* (whereClause)? # update
190188 | KW_MERGE KW_INTO tableRef (KW_AS ? identifier)? KW_USING relation KW_ON expression mergeCase+ # merge
191189 | KW_SHOW KW_COMMENT KW_ON KW_TABLE tableRef # showTableComment // dtstack
192190 | KW_SHOW KW_COMMENT KW_ON KW_COLUMN columnRef # showColumnComment // dtstack
@@ -283,12 +281,16 @@ sortItem
283281
284282querySpecification
285283 : KW_SELECT setQuantifier? selectItem (' ,' selectItem)* (KW_FROM relation (' ,' relation)*)? (
286- KW_WHERE where=booleanExpression
284+ whereClause
287285 )? (KW_GROUP KW_BY groupBy)? (KW_HAVING having=booleanExpression)? (
288286 KW_WINDOW windowDefinition (' ,' windowDefinition)*
289287 )?
290288 ;
291289
290+ whereClause
291+ : KW_WHERE where=booleanExpression
292+ ;
293+
292294groupBy
293295 : setQuantifier? groupingElement (' ,' groupingElement)*
294296 ;
@@ -590,7 +592,7 @@ primaryExpression
590592 | KW_TRY_CAST ' (' expression KW_AS type ' )' # cast
591593 | KW_ARRAY ' [' (expression (' ,' expression)*)? ' ]' # arrayConstructor
592594 | value=primaryExpression ' [' index=valueExpression ' ]' # subscript
593- | identifier # columnReference
595+ | columnName # columnReference
594596 | base=primaryExpression ' .' fieldName=identifier # dereference
595597 | name=KW_CURRENT_DATE # currentDate
596598 | name=KW_CURRENT_TIME (' (' precision=INTEGER_VALUE ' )' )? # currentTime
@@ -765,7 +767,7 @@ whenClause
765767 ;
766768
767769filter
768- : KW_FILTER ' (' KW_WHERE booleanExpression ' )'
770+ : KW_FILTER ' (' whereClause ' )'
769771 ;
770772
771773mergeCase
@@ -1008,6 +1010,10 @@ columnRef
10081010 | {this.shouldMatchEmpty()} ?
10091011 ;
10101012
1013+ columnName
1014+ : qualifiedName
1015+ ;
1016+
10111017columnNameCreate
10121018 : identifier
10131019 ;
0 commit comments