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
3 changes: 3 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 @@ -305,6 +306,7 @@ KW_PERCENTILE_DISC : 'PERCENTILE_DISC';
KW_PERCENT_RANK : 'PERCENT_RANK';
KW_PERIOD : 'PERIOD';
KW_PERMUTE : 'PERMUTE';
KW_RETURNING : 'RETURNING';
KW_PIVOT : 'PIVOT';
KW_PORTION : 'PORTION';
KW_POSITION : 'POSITION';
Expand Down Expand Up @@ -428,6 +430,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
36 changes: 28 additions & 8 deletions src/grammar/flink/FlinkSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ projectItemDefinition
;

overWindowItem
: primaryExpression KW_OVER windowSpec KW_AS identifier
| primaryExpression KW_OVER errorCapturingIdentifier KW_AS identifier
: primaryExpression KW_OVER windowSpec (KW_AS identifier)?
| primaryExpression KW_OVER errorCapturingIdentifier (KW_AS identifier)?
;

fromClause
Expand Down Expand Up @@ -644,7 +644,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 @@ -694,13 +696,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,11 +789,12 @@ 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
| jsonValueExpression # jsonValue
// | (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 All @@ -787,6 +803,10 @@ primaryExpression
// KW_FROM position=valueExpression (KW_FOR length=valueExpression)? RR_BRACKET #overlay
;

jsonValueExpression
: KW_JSON_VALUE LR_BRACKET expression COMMA stringLiteral (KW_RETURNING columnType)? RR_BRACKET
;

functionNameCreate
: uid
;
Expand Down
11 changes: 10 additions & 1 deletion src/lib/flink/FlinkSqlLexer.interp

Large diffs are not rendered by default.

Loading