Skip to content

Commit fbcc9bf

Browse files
authored
Merge pull request #459 from Cythia828/fix_455
fix(flink): #455 fix json functions' params problem in flink
2 parents df42c79 + 12ef949 commit fbcc9bf

File tree

6 files changed

+4141
-2605
lines changed

6 files changed

+4141
-2605
lines changed

src/grammar/flink/FlinkSqlParser.g4

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,15 @@ predicate
738738
| KW_IS KW_JSON (KW_VALUE | KW_ARRAY | identifier)?
739739
;
740740

741+
jsonFunctionBranch
742+
: KW_NULL
743+
| KW_EMPTY KW_ARRAY
744+
| KW_EMPTY uid
745+
| KW_TRUE
746+
| KW_FALSE
747+
| KW_UNKNOWN
748+
;
749+
741750
likePredicate
742751
: KW_NOT? kind=KW_LIKE quantifier=(KW_ANY | KW_ALL) (
743752
LR_BRACKET RR_BRACKET
@@ -825,6 +834,36 @@ functionParam
825834
| timeIntervalUnit
826835
| timePointUnit
827836
| expression
837+
| jsonValueParams
838+
| jsonQueryParams
839+
| jsonObjectParams
840+
| jsonArrayParams
841+
;
842+
843+
jsonValueParams
844+
: columnNamePath (uid columnType)? (
845+
(uid | KW_NULL | KW_DEFAULT valueExpression) KW_ON KW_EMPTY
846+
)? ((uid | KW_NULL | KW_DEFAULT valueExpression) KW_ON uid)?
847+
;
848+
849+
jsonQueryParams
850+
: columnNamePath ((KW_WITHOUT | KW_WITH uid?) KW_ARRAY? uid)? (
851+
jsonFunctionBranch KW_ON KW_EMPTY
852+
)? (jsonFunctionBranch KW_ON uid)?
853+
;
854+
855+
// JSON 函数只能在 JSON_OBJECT 函数中使用
856+
jsonObjectParams
857+
: (
858+
KW_KEY? columnNamePath KW_VALUE? (
859+
valueExpression
860+
| KW_JSON LR_BRACKET (valueExpression)* RR_BRACKET
861+
)
862+
)* ((KW_NULL | uid) KW_ON KW_NULL)?
863+
;
864+
865+
jsonArrayParams
866+
: valueExpression* ((KW_NULL | uid) KW_ON KW_NULL)?
828867
;
829868

830869
dereferenceDefinition

src/lib/flink/FlinkSqlParser.interp

Lines changed: 6 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)