Skip to content

Commit 845ad8a

Browse files
author
zhaoge
committed
fix(flink): #398 optimize flink g4 rule
1 parent 012eb61 commit 845ad8a

File tree

6 files changed

+2845
-2997
lines changed

6 files changed

+2845
-2997
lines changed

src/grammar/flink/FlinkSqlParser.g4

+8-12
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,7 @@ tableReference
515515
tablePrimary
516516
: KW_TABLE? tablePath systemTimePeriod?
517517
| viewPath systemTimePeriod?
518-
| KW_LATERAL KW_TABLE LR_BRACKET (
519-
(functionNameWithParams LR_BRACKET functionParam (COMMA functionParam)* RR_BRACKET)
520-
| reservedKeywordsNoParamsUsedAsFuncName
521-
| functionNameAndParams
522-
) RR_BRACKET
518+
| KW_LATERAL KW_TABLE LR_BRACKET functionCallExpression RR_BRACKET
523519
| KW_LATERAL? LR_BRACKET queryStatement RR_BRACKET
524520
| KW_UNNEST LR_BRACKET expression RR_BRACKET
525521
;
@@ -751,6 +747,12 @@ valueExpression
751747
| left=valueExpression comparisonOperator right=valueExpression # comparison
752748
;
753749

750+
functionCallExpression
751+
: reservedKeywordsNoParamsUsedAsFuncName
752+
| functionNameAndParams
753+
| functionNameWithParams LR_BRACKET (setQuantifier? functionParam (COMMA functionParam)*)? RR_BRACKET
754+
;
755+
754756
primaryExpression
755757
: KW_CASE whenClause+ (KW_ELSE elseExpression=expression)? KW_END # searchedCase
756758
| KW_CASE value=expression whenClause+ (KW_ELSE elseExpression=expression)? KW_END # simpleCase
@@ -764,13 +766,7 @@ primaryExpression
764766
| uid DOT ASTERISK_SIGN # star
765767
// | LR_BRACKET namedExpression (COMMA namedExpression)+ RR_BRACKET #rowConstructor
766768
| 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
769+
| functionCallExpression # functionCall
774770
// | identifier '->' expression #lambda
775771
// | '(' identifier (',' identifier)+ ')' '->' expression #lambda
776772
| value=primaryExpression LS_BRACKET index=valueExpression RS_BRACKET # subscript

src/lib/flink/FlinkSqlParser.interp

+2-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)