@@ -487,8 +487,8 @@ selectClause
487
487
488
488
projectItemDefinition
489
489
: overWindowItem
490
- | columnName (KW_AS ? expression)?
491
490
| expression (KW_AS ? columnName)?
491
+ | columnName (KW_AS ? expression)?
492
492
;
493
493
494
494
overWindowItem
@@ -515,7 +515,11 @@ tableReference
515
515
tablePrimary
516
516
: KW_TABLE ? tablePath systemTimePeriod?
517
517
| viewPath systemTimePeriod?
518
- | KW_LATERAL KW_TABLE LR_BRACKET functionName LR_BRACKET functionParam (COMMA functionParam)* RR_BRACKET RR_BRACKET
518
+ | KW_LATERAL KW_TABLE LR_BRACKET (
519
+ (functionNameWithParams LR_BRACKET functionParam (COMMA functionParam)* RR_BRACKET )
520
+ | reservedKeywordsNoParamsUsedAsFuncName
521
+ | functionNameAndParams
522
+ ) RR_BRACKET
519
523
| KW_LATERAL ? LR_BRACKET queryStatement RR_BRACKET
520
524
| KW_UNNEST LR_BRACKET expression RR_BRACKET
521
525
;
@@ -759,15 +763,20 @@ primaryExpression
759
763
| ASTERISK_SIGN # star
760
764
| uid DOT ASTERISK_SIGN # star
761
765
// | LR_BRACKET namedExpression (COMMA namedExpression)+ RR_BRACKET #rowConstructor
762
- | LR_BRACKET queryStatement RR_BRACKET # subqueryExpression
763
- | functionName LR_BRACKET (setQuantifier? functionParam (COMMA functionParam)*)? RR_BRACKET # functionCall
766
+ | LR_BRACKET queryStatement RR_BRACKET # subqueryExpression
767
+ | (
768
+ reservedKeywordsNoParamsUsedAsFuncName
769
+ | functionNameAndParams
770
+ | (
771
+ functionNameWithParams LR_BRACKET (setQuantifier? functionParam (COMMA functionParam)*)? RR_BRACKET
772
+ )
773
+ ) # functionCall
764
774
// | identifier '->' expression #lambda
765
775
// | '(' identifier (',' identifier)+ ')' '->' expression #lambda
766
776
| value=primaryExpression LS_BRACKET index=valueExpression RS_BRACKET # subscript
767
777
| identifier # columnReference
768
778
| dereferenceDefinition # dereference
769
779
| LR_BRACKET expression RR_BRACKET # parenthesizedExpression
770
- | KW_CURRENT_TIMESTAMP # dateFunctionExpression
771
780
// | EXTRACT LR_BRACKET field=identifier KW_FROM source=valueExpression RR_BRACKET #extract
772
781
// | (SUBSTR | SUBSTRING) LR_BRACKET str=valueExpression (KW_FROM | COMMA) pos=valueExpression
773
782
// ((KW_FOR | COMMA) len=valueExpression)? RR_BRACKET #substring
@@ -782,6 +791,25 @@ functionNameCreate
782
791
;
783
792
784
793
functionName
794
+ : reservedKeywordsUsedAsFuncName
795
+ | reservedKeywordsNoParamsUsedAsFuncName
796
+ | reservedKeywordsFollowParamsUsedAsFuncName
797
+ | uid
798
+ ;
799
+
800
+ /* *
801
+ * Built-in function name that is following with params directly without parentheses
802
+ * Reference Link:https://nightlies.apache.org/flink/flink-docs-release-1.16/zh/docs/dev/table/functions/systemfunctions/#%E6%97%B6%E9%97%B4%E5%87%BD%E6%95%B0
803
+ */
804
+ functionNameAndParams
805
+ : reservedKeywordsFollowParamsUsedAsFuncName STRING_LITERAL
806
+ | timeIntervalExpression
807
+ ;
808
+
809
+ /* *
810
+ * Function name that is need to follow with parentheses and params
811
+ */
812
+ functionNameWithParams
785
813
: reservedKeywordsUsedAsFuncName
786
814
| uid
787
815
;
@@ -1077,6 +1105,23 @@ reservedKeywordsUsedAsFuncParam
1077
1105
| ASTERISK_SIGN
1078
1106
;
1079
1107
1108
+ /* *
1109
+ * Built-in function name without parentheses and params
1110
+ */
1111
+ reservedKeywordsNoParamsUsedAsFuncName
1112
+ : KW_LOCALTIME
1113
+ | KW_LOCALTIMESTAMP
1114
+ | KW_CURRENT_TIME
1115
+ | KW_CURRENT_DATE
1116
+ | KW_CURRENT_TIMESTAMP
1117
+ ;
1118
+
1119
+ reservedKeywordsFollowParamsUsedAsFuncName
1120
+ : KW_DATE
1121
+ | KW_TIME
1122
+ | KW_TIMESTAMP
1123
+ ;
1124
+
1080
1125
reservedKeywordsUsedAsFuncName
1081
1126
: KW_ABS
1082
1127
| KW_ARRAY
@@ -1089,10 +1134,6 @@ reservedKeywordsUsedAsFuncName
1089
1134
| KW_COLLECT
1090
1135
| KW_COUNT
1091
1136
| KW_CUME_DIST
1092
- | KW_CURRENT_DATE
1093
- | KW_CURRENT_TIME
1094
- | KW_CURRENT_TIMESTAMP
1095
- | KW_DATE
1096
1137
| KW_DAYOFWEEK
1097
1138
| KW_DAYOFYEAR
1098
1139
| KW_DENSE_RANK
@@ -1109,8 +1150,6 @@ reservedKeywordsUsedAsFuncName
1109
1150
| KW_LEAD
1110
1151
| KW_LEFT
1111
1152
| KW_LN
1112
- | KW_LOCALTIME
1113
- | KW_LOCALTIMESTAMP
1114
1153
| KW_LOWER
1115
1154
| KW_MAP
1116
1155
| KW_MAX
@@ -1135,8 +1174,6 @@ reservedKeywordsUsedAsFuncName
1135
1174
| KW_STDDEV_SAMP
1136
1175
| KW_SUBSTRING
1137
1176
| KW_SUM
1138
- | KW_TIME
1139
- | KW_TIMESTAMP
1140
1177
| KW_TIMESTAMP_DIFF
1141
1178
| KW_TRIM
1142
1179
| KW_TRUNCATE
0 commit comments