@@ -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,7 @@ 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 functionCallExpression RR_BRACKET
519
519
| KW_LATERAL ? LR_BRACKET queryStatement RR_BRACKET
520
520
| KW_UNNEST LR_BRACKET expression RR_BRACKET
521
521
;
@@ -747,6 +747,12 @@ valueExpression
747
747
| left=valueExpression comparisonOperator right=valueExpression # comparison
748
748
;
749
749
750
+ functionCallExpression
751
+ : reservedKeywordsNoParamsUsedAsFuncName
752
+ | functionNameAndParams
753
+ | functionNameWithParams LR_BRACKET (setQuantifier? functionParam (COMMA functionParam)*)? RR_BRACKET
754
+ ;
755
+
750
756
primaryExpression
751
757
: KW_CASE whenClause+ (KW_ELSE elseExpression=expression)? KW_END # searchedCase
752
758
| KW_CASE value=expression whenClause+ (KW_ELSE elseExpression=expression)? KW_END # simpleCase
@@ -759,15 +765,14 @@ primaryExpression
759
765
| ASTERISK_SIGN # star
760
766
| uid DOT ASTERISK_SIGN # star
761
767
// | 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
768
+ | LR_BRACKET queryStatement RR_BRACKET # subqueryExpression
769
+ | functionCallExpression # functionCall
764
770
// | identifier '->' expression #lambda
765
771
// | '(' identifier (',' identifier)+ ')' '->' expression #lambda
766
772
| value=primaryExpression LS_BRACKET index=valueExpression RS_BRACKET # subscript
767
773
| identifier # columnReference
768
774
| dereferenceDefinition # dereference
769
775
| LR_BRACKET expression RR_BRACKET # parenthesizedExpression
770
- | KW_CURRENT_TIMESTAMP # dateFunctionExpression
771
776
// | EXTRACT LR_BRACKET field=identifier KW_FROM source=valueExpression RR_BRACKET #extract
772
777
// | (SUBSTR | SUBSTRING) LR_BRACKET str=valueExpression (KW_FROM | COMMA) pos=valueExpression
773
778
// ((KW_FOR | COMMA) len=valueExpression)? RR_BRACKET #substring
@@ -782,6 +787,25 @@ functionNameCreate
782
787
;
783
788
784
789
functionName
790
+ : reservedKeywordsUsedAsFuncName
791
+ | reservedKeywordsNoParamsUsedAsFuncName
792
+ | reservedKeywordsFollowParamsUsedAsFuncName
793
+ | uid
794
+ ;
795
+
796
+ /* *
797
+ * Built-in function name that is following with params directly without parentheses
798
+ * 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
799
+ */
800
+ functionNameAndParams
801
+ : reservedKeywordsFollowParamsUsedAsFuncName STRING_LITERAL
802
+ | timeIntervalExpression
803
+ ;
804
+
805
+ /* *
806
+ * Function name that is need to follow with parentheses and params
807
+ */
808
+ functionNameWithParams
785
809
: reservedKeywordsUsedAsFuncName
786
810
| uid
787
811
;
@@ -1077,6 +1101,23 @@ reservedKeywordsUsedAsFuncParam
1077
1101
| ASTERISK_SIGN
1078
1102
;
1079
1103
1104
+ /* *
1105
+ * Built-in function name without parentheses and params
1106
+ */
1107
+ reservedKeywordsNoParamsUsedAsFuncName
1108
+ : KW_LOCALTIME
1109
+ | KW_LOCALTIMESTAMP
1110
+ | KW_CURRENT_TIME
1111
+ | KW_CURRENT_DATE
1112
+ | KW_CURRENT_TIMESTAMP
1113
+ ;
1114
+
1115
+ reservedKeywordsFollowParamsUsedAsFuncName
1116
+ : KW_DATE
1117
+ | KW_TIME
1118
+ | KW_TIMESTAMP
1119
+ ;
1120
+
1080
1121
reservedKeywordsUsedAsFuncName
1081
1122
: KW_ABS
1082
1123
| KW_ARRAY
@@ -1089,10 +1130,6 @@ reservedKeywordsUsedAsFuncName
1089
1130
| KW_COLLECT
1090
1131
| KW_COUNT
1091
1132
| KW_CUME_DIST
1092
- | KW_CURRENT_DATE
1093
- | KW_CURRENT_TIME
1094
- | KW_CURRENT_TIMESTAMP
1095
- | KW_DATE
1096
1133
| KW_DAYOFWEEK
1097
1134
| KW_DAYOFYEAR
1098
1135
| KW_DENSE_RANK
@@ -1109,8 +1146,6 @@ reservedKeywordsUsedAsFuncName
1109
1146
| KW_LEAD
1110
1147
| KW_LEFT
1111
1148
| KW_LN
1112
- | KW_LOCALTIME
1113
- | KW_LOCALTIMESTAMP
1114
1149
| KW_LOWER
1115
1150
| KW_MAP
1116
1151
| KW_MAX
@@ -1135,8 +1170,6 @@ reservedKeywordsUsedAsFuncName
1135
1170
| KW_STDDEV_SAMP
1136
1171
| KW_SUBSTRING
1137
1172
| KW_SUM
1138
- | KW_TIME
1139
- | KW_TIMESTAMP
1140
1173
| KW_TIMESTAMP_DIFF
1141
1174
| KW_TRIM
1142
1175
| KW_TRUNCATE
0 commit comments