Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [4.5.0-beta.0](https://github.com/DTStack/dt-sql-parser/compare/v4.4.1...v4.5.0-beta.0) (2025-12-30)
### [4.4.2](https://github.com/DTStack/dt-sql-parser/compare/v4.4.1...v4.4.2) (2026-03-06)


### Bug Fixes

* **flink:** [#455](https://github.com/DTStack/dt-sql-parser/issues/455) fix json functions' params problem in flink ([12ef949](https://github.com/DTStack/dt-sql-parser/commit/12ef949339ffb0889e428c97c54149cd567b6ae8))
* **flink:** some grammar rules ([#465](https://github.com/DTStack/dt-sql-parser/issues/465)) ([20e352c](https://github.com/DTStack/dt-sql-parser/commit/20e352cb32142c825ee086e36051ff9797798e09)), closes [#464](https://github.com/DTStack/dt-sql-parser/issues/464) [#464](https://github.com/DTStack/dt-sql-parser/issues/464) [#464](https://github.com/DTStack/dt-sql-parser/issues/464)


### Features
Expand Down
2 changes: 2 additions & 0 deletions src/grammar/flink/FlinkSqlLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ KW_FILTER : 'FILTER';
KW_FIRST_VALUE : 'FIRST_VALUE';
KW_FLOAT : 'FLOAT';
KW_FLOOR : 'FLOOR';
KW_FOLLOWING : 'FOLLOWING';
KW_FOR : 'FOR';
KW_FOREIGN : 'FOREIGN';
KW_FRAME_ROW : 'FRAME_ROW';
Expand Down Expand Up @@ -428,6 +429,7 @@ KW_TRUNCATE : 'TRUNCATE';
KW_TRY_CAST : 'TRY_CAST';
KW_TUESDAY : 'TUESDAY';
KW_UESCAPE : 'UESCAPE';
KW_UNBOUNDED : 'UNBOUNDED';
KW_UNION : 'UNION';
KW_UNIQUE : 'UNIQUE';
KW_UNKNOWN : 'UNKNOWN';
Expand Down
66 changes: 60 additions & 6 deletions src/grammar/flink/FlinkSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@ orderByClause
;

orderItemDefinition
: columnName ordering=(KW_ASC | KW_DESC)? (KW_NULLS nullOrder=(KW_LAST | KW_FIRST))?
: (columnName | valueExpression) ordering=(KW_ASC | KW_DESC)? (
KW_NULLS nullOrder=(KW_LAST | KW_FIRST)
)?
;

limitClause
Expand Down Expand Up @@ -735,13 +737,26 @@ patternVariablesDefinition

windowFrame
: KW_RANGE KW_BETWEEN timeIntervalExpression frameBound
| (KW_ROWS | KW_RANGE) KW_BETWEEN frameStart KW_AND frameEnd
| KW_ROWS KW_BETWEEN DIG_LITERAL frameBound
;

frameBound
: KW_PRECEDING KW_AND KW_CURRENT KW_ROW
;

frameStart
: KW_UNBOUNDED KW_PRECEDING
| DIG_LITERAL KW_PRECEDING
| KW_CURRENT KW_ROW
;

frameEnd
: KW_CURRENT KW_ROW
| DIG_LITERAL KW_FOLLOWING
| KW_UNBOUNDED KW_FOLLOWING
;

withinClause
: KW_WITHIN timeIntervalExpression
;
Expand Down Expand Up @@ -774,6 +789,15 @@ predicate
| KW_IS KW_JSON (KW_VALUE | KW_ARRAY | identifier)?
;

jsonFunctionBranch
: KW_NULL
| KW_EMPTY KW_ARRAY
| KW_EMPTY uid
| KW_TRUE
| KW_FALSE
| KW_UNKNOWN
;

likePredicate
: KW_NOT? kind=KW_LIKE quantifier=(KW_ANY | KW_ALL) (
LR_BRACKET RR_BRACKET
Expand Down Expand Up @@ -815,11 +839,11 @@ primaryExpression
| functionCallExpression # functionCall
// | identifier '->' expression #lambda
// | '(' identifier (',' identifier)+ ')' '->' expression #lambda
| value=primaryExpression LS_BRACKET index=valueExpression RS_BRACKET # subscript
| columnNamePath # columnReference
| dereferenceDefinition # dereference
| LR_BRACKET expression RR_BRACKET # parenthesizedExpression
// | EXTRACT LR_BRACKET field=identifier KW_FROM source=valueExpression RR_BRACKET #extract
| value=primaryExpression LS_BRACKET index=valueExpression RS_BRACKET # subscript
| columnNamePath # columnReference
| dereferenceDefinition # dereference
| LR_BRACKET expression RR_BRACKET # parenthesizedExpression
| KW_EXTRACT LR_BRACKET field=identifier KW_FROM source=valueExpression RR_BRACKET # extract
// | (SUBSTR | SUBSTRING) LR_BRACKET str=valueExpression (KW_FROM | COMMA) pos=valueExpression
// ((KW_FOR | COMMA) len=valueExpression)? RR_BRACKET #substring
// | TRIM LR_BRACKET trimOption=(BOTH | LEADING | TRAILING)? (trimStr=valueExpression)?
Expand Down Expand Up @@ -861,6 +885,36 @@ functionParam
| timeIntervalUnit
| timePointUnit
| expression
| jsonValueParams
| jsonQueryParams
| jsonObjectParams
| jsonArrayParams
;

jsonValueParams
: columnNamePath (uid columnType)? (
(uid | KW_NULL | KW_DEFAULT valueExpression) KW_ON KW_EMPTY
)? ((uid | KW_NULL | KW_DEFAULT valueExpression) KW_ON uid)?
;

jsonQueryParams
: columnNamePath ((KW_WITHOUT | KW_WITH uid?) KW_ARRAY? uid)? (
jsonFunctionBranch KW_ON KW_EMPTY
)? (jsonFunctionBranch KW_ON uid)?
;

// JSON 函数只能在 JSON_OBJECT 函数中使用
jsonObjectParams
: (
KW_KEY? columnNamePath KW_VALUE? (
valueExpression
| KW_JSON LR_BRACKET (valueExpression)* RR_BRACKET
)
)* ((KW_NULL | uid) KW_ON KW_NULL)?
;

jsonArrayParams
: valueExpression* ((KW_NULL | uid) KW_ON KW_NULL)?
;

dereferenceDefinition
Expand Down
8 changes: 7 additions & 1 deletion src/lib/flink/FlinkSqlLexer.interp

Large diffs are not rendered by default.

Loading
Loading