Skip to content

Commit 7224ac9

Browse files
committed
fix: #464 order by + expression
1 parent fbcc9bf commit 7224ac9

11 files changed

Lines changed: 7843 additions & 7495 deletions

File tree

src/grammar/flink/FlinkSqlLexer.g4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ KW_FILTER : 'FILTER';
171171
KW_FIRST_VALUE : 'FIRST_VALUE';
172172
KW_FLOAT : 'FLOAT';
173173
KW_FLOOR : 'FLOOR';
174+
KW_FOLLOWING : 'FOLLOWING';
174175
KW_FOR : 'FOR';
175176
KW_FOREIGN : 'FOREIGN';
176177
KW_FRAME_ROW : 'FRAME_ROW';
@@ -428,6 +429,7 @@ KW_TRUNCATE : 'TRUNCATE';
428429
KW_TRY_CAST : 'TRY_CAST';
429430
KW_TUESDAY : 'TUESDAY';
430431
KW_UESCAPE : 'UESCAPE';
432+
KW_UNBOUNDED : 'UNBOUNDED';
431433
KW_UNION : 'UNION';
432434
KW_UNIQUE : 'UNIQUE';
433435
KW_UNKNOWN : 'UNKNOWN';

src/grammar/flink/FlinkSqlParser.g4

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,9 @@ orderByClause
649649
;
650650

651651
orderItemDefinition
652-
: columnName ordering=(KW_ASC | KW_DESC)? (KW_NULLS nullOrder=(KW_LAST | KW_FIRST))?
652+
: (columnName | valueExpression) ordering=(KW_ASC | KW_DESC)? (
653+
KW_NULLS nullOrder=(KW_LAST | KW_FIRST)
654+
)?
653655
;
654656

655657
limitClause
@@ -699,13 +701,26 @@ patternVariablesDefinition
699701

700702
windowFrame
701703
: KW_RANGE KW_BETWEEN timeIntervalExpression frameBound
704+
| (KW_ROWS | KW_RANGE) KW_BETWEEN frameStart KW_AND frameEnd
702705
| KW_ROWS KW_BETWEEN DIG_LITERAL frameBound
703706
;
704707

705708
frameBound
706709
: KW_PRECEDING KW_AND KW_CURRENT KW_ROW
707710
;
708711

712+
frameStart
713+
: KW_UNBOUNDED KW_PRECEDING
714+
| DIG_LITERAL KW_PRECEDING
715+
| KW_CURRENT KW_ROW
716+
;
717+
718+
frameEnd
719+
: KW_CURRENT KW_ROW
720+
| DIG_LITERAL KW_FOLLOWING
721+
| KW_UNBOUNDED KW_FOLLOWING
722+
;
723+
709724
withinClause
710725
: KW_WITHIN timeIntervalExpression
711726
;

src/lib/flink/FlinkSqlLexer.interp

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

0 commit comments

Comments
 (0)