feat: complete Query statements of FlinkSQL (#93)

* feat: add inlineDataValueClasue rule

* test: update tests of select statements

* feat: support flinksql window TVF grammar

* test: flink sql windown TVF statement test

* feat: support grouping sets grammar

* test: window TVF Aggregation and Group Window Aggregation tests

* test: supplemental selectAggregation with test cases

* test: add Having statement test case

* feat: support flinkSql over aggregation grammar

* test: add over aggregation grammar test cases

* test: flink sql join statement test cases

* test: flink sql set Operations grammar test cases

* test: flink sql limit clause test case

* feat: remove allPlusUid and replace with uid

* feat: support flink sql pattern recognition grammar

* test: flink sql pattern recognition tests

* feat: add flink sql with clause rule

* test: flink sql with clasue select tests

* feat: rebuild flink sql parser
This commit is contained in:
Hayden 2023-05-17 10:30:25 +08:00 committed by GitHub
parent fbee70cde5
commit a026ae0592
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 8188 additions and 4486 deletions

View File

@ -273,6 +273,24 @@ ENFORCED: 'ENFORCED';
METADATA: 'METADATA';
VIRTUAL: 'VIRTUAL';
ZONE: 'ZONE';
TUMBLE: 'TUMBLE';
HOP: 'HOP';
CUMULATE: 'CUMULATE';
DESCRIPTOR: 'DESCRIPTOR';
TIMECOL: 'TIMECOL';
SIZE: 'SIZE';
OFFSET: 'OFFSET';
STEP: 'STEP';
SLIDE: 'SLIDE';
SESSION: 'SESSION';
MATCH_RECOGNIZE: 'MATCH_RECOGNIZE';
MEASURES: 'MEASURES';
PATTERN: 'PATTERN';
ONE: 'ONE';
PER: 'PER';
KW_SKIP: 'SKIP';
PAST: 'PAST';
DEFINE: 'DEFINE';
// DATA TYPE Keywords
@ -330,6 +348,8 @@ LS_BRACKET: '[';
RS_BRACKET: ']';
LR_BRACKET: '(';
RR_BRACKET: ')';
LB_BRACKET: '{';
RB_BRACKET: '}';
COMMA: ',';
SEMICOLON: ';';
AT_SIGN: '@';
@ -345,8 +365,8 @@ PENCENT_SIGN: '%';
DOUBLE_VERTICAL_SIGN: '||';
DOUBLE_HYPNEN_SIGN: '--';
SLASH_SIGN: '/';
QUESTION_MARK_SIGN: '?';
DOT_ID: '.' ID_LITERAL_FRAG;
PLUS_DOT_ID: (':' | '.') PLUS_ID_LITERAL;
STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING;
DIG_LITERAL: DEC_DIGIT+;
REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
@ -355,14 +375,13 @@ REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
| DEC_DIGIT+ EXPONENT_NUM_PART;
BIT_STRING: BIT_STRING_L;
ID_LITERAL: ID_LITERAL_FRAG;
PLUS_ID_LITERAL: PLUS_ID_LITERAL_FRAG;
FILE_PATH: FILE_PATH_STRING;
DOUBLE_ARROW: '=>';
fragment FILE_PATH_STRING: ([/\\] (~([/\\ ]))*)+;
fragment JAR_FILE_PARTTARN: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';
fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+;
fragment ID_LITERAL_FRAG: [A-Z_0-9a-z]*?[A-Z_a-z]+?[A-Z_0-9a-z]*;
fragment PLUS_ID_LITERAL_FRAG: [A-Z_0-9a-z*@#^$%&{}]*?[A-Z_a-z*@#^$%&{}]+?[A-Z_0-9a-z*@#^$%&{}]*;
fragment DEC_DIGIT: [0-9];
fragment DEC_LETTER: [A-Za-z];
fragment DQUOTA_STRING: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';

View File

@ -134,7 +134,7 @@ physicalColumnDefinition
;
columnName
: plusUid | expression
: uid | expression
;
columnNameList
@ -380,7 +380,7 @@ insertMulStatement
queryStatement
: valuesCaluse
| WITH withItem (COMMA withItem)* queryStatement
| withClause queryStatement
| '(' queryStatement ')'
| left=queryStatement operator=(INTERSECT | UNION | EXCEPT) ALL? right=queryStatement orderByCaluse? limitClause?
| selectClause orderByCaluse? limitClause?
@ -391,6 +391,10 @@ valuesCaluse
: VALUES expression (COMMA expression )*
;
withClause
: WITH withItem (COMMA withItem)*
;
withItem
: withItemName (LR_BRACKET columnName (COMMA columnName)* RR_BRACKET)? AS LR_BRACKET queryStatement RR_BRACKET
;
@ -401,6 +405,7 @@ withItemName
selectStatement
: selectClause fromClause whereClause? groupByClause? havingClause? windowClause?
| selectClause fromClause matchRecognizeClause
;
selectClause
@ -408,7 +413,13 @@ selectClause
;
projectItemDefinition
: expression (AS? expression)?
: overWindowItem
| expression (AS? expression)?
;
overWindowItem
: primaryExpression OVER windowSpec AS strictIdentifier
| primaryExpression OVER errorCapturingIdentifier AS strictIdentifier
;
fromClause
@ -419,6 +430,8 @@ tableExpression
: tableReference (COMMA tableReference)*
| tableExpression NATURAL? (LEFT | RIGHT | FULL | INNER)? OUTER? JOIN tableExpression joinCondition?
| tableExpression CROSS JOIN tableExpression
| inlineDataValueClause
| windoTVFClause
;
tableReference
@ -444,6 +457,46 @@ dateTimeExpression
: expression
;
inlineDataValueClause
: LR_BRACKET valuesDefinition RR_BRACKET tableAlias
;
windoTVFClause
: TABLE LR_BRACKET windowTVFExression RR_BRACKET
;
windowTVFExression
: windoTVFName LR_BRACKET windowTVFParam (COMMA windowTVFParam)* RR_BRACKET
;
windoTVFName
: TUMBLE
| HOP
| CUMULATE
;
windowTVFParam
: TABLE timeAttrColumn
| columnDescriptor
| timeIntervalExpression
| DATA DOUBLE_ARROW TABLE timeAttrColumn
| TIMECOL DOUBLE_ARROW columnDescriptor
| timeIntervalParamName DOUBLE_ARROW timeIntervalExpression
;
timeIntervalParamName
: DATA
| TIMECOL
| SIZE
| OFFSET
| STEP
| SLIDE
;
columnDescriptor
: DESCRIPTOR LR_BRACKET uid RR_BRACKET
;
joinCondition
: ON booleanExpression
| USING LR_BRACKET uid (COMMA uid)* RR_BRACKET
@ -459,29 +512,40 @@ groupByClause
groupItemDefinition
: expression
| groupWindowFunction
| LR_BRACKET RR_BRACKET
| LR_BRACKET expression (COMMA expression)* RR_BRACKET
| CUBE LR_BRACKET expression (COMMA expression)* RR_BRACKET
| ROLLUP LR_BRACKET expression (COMMA expression)* RR_BRACKET
| GROUPING SETS LR_BRACKET groupItemDefinition (COMMA groupItemDefinition)* RR_BRACKET
| groupingSetsNotaionName LR_BRACKET expression (COMMA expression)* RR_BRACKET
| groupingSets LR_BRACKET groupItemDefinition (COMMA groupItemDefinition)* RR_BRACKET
;
groupingSets
: GROUPING SETS
;
groupingSetsNotaionName
: CUBE
| ROLLUP
;
groupWindowFunction
: groupWindowFunctionName LR_BRACKET timeAttrColumn COMMA timeIntervalExpression RR_BRACKET
;
groupWindowFunctionName
: TUMBLE
| HOP
| SESSION
;
timeAttrColumn
: uid
;
havingClause
: HAVING booleanExpression
;
orderByCaluse
: ORDER BY orderItemDefition (COMMA orderItemDefition)*
;
orderItemDefition
: expression (ASC | DESC)?
;
limitClause
: LIMIT (ALL | limit=expression)
;
windowClause
: WINDOW namedWindow (',' namedWindow)*
;
@ -492,26 +556,99 @@ namedWindow
windowSpec
: name=errorCapturingIdentifier?
'('
(ORDER BY sortItem (',' sortItem)*)?
(PARTITION BY expression (',' expression)*)?
LR_BRACKET
partitionByClause?
orderByCaluse?
windowFrame?
')'
RR_BRACKET
;
sortItem
matchRecognizeClause
: MATCH_RECOGNIZE
LR_BRACKET
partitionByClause?
orderByCaluse?
measuresClause?
outputMode?
afterMatchStrategy?
patternDefination?
patternVariablesDefination
RR_BRACKET ( AS? strictIdentifier )?
;
orderByCaluse
: ORDER BY orderItemDefition (COMMA orderItemDefition)*
;
orderItemDefition
: expression ordering=(ASC | DESC)? (NULLS nullOrder=(LAST | FIRST))?
;
limitClause
: LIMIT (ALL | limit=expression)
;
partitionByClause
: PARTITION BY expression (COMMA expression)*
;
quantifiers
: (ASTERISK_SIGN)
| (ADD_SIGN)
| (QUESTION_MARK_SIGN)
| (LB_BRACKET DIG_LITERAL COMMA DIG_LITERAL RB_BRACKET)
| (LB_BRACKET DIG_LITERAL COMMA RB_BRACKET)
| (LB_BRACKET COMMA DIG_LITERAL RB_BRACKET)
;
measuresClause
: MEASURES projectItemDefinition (COMMA projectItemDefinition)*
;
patternDefination
: PATTERN
LR_BRACKET
patternVariable+
RR_BRACKET
withinClause?
;
patternVariable
: unquotedIdentifier quantifiers?
;
outputMode
: ALL ROWS PER MATCH
| ONE ROW PER MATCH
;
afterMatchStrategy
: AFTER MATCH KW_SKIP PAST LAST ROW
| AFTER MATCH KW_SKIP TO NEXT ROW
| AFTER MATCH KW_SKIP TO LAST unquotedIdentifier
| AFTER MATCH KW_SKIP TO FIRST unquotedIdentifier
;
patternVariablesDefination
: DEFINE projectItemDefinition (COMMA projectItemDefinition)*
;
windowFrame
: RANGE frameBound
| ROWS frameBound
: RANGE BETWEEN timeIntervalExpression frameBound
| ROWS BETWEEN DIG_LITERAL frameBound
;
frameBound
: expression PRECEDING
: PRECEDING AND CURRENT ROW
;
withinClause
: WITHIN timeIntervalExpression
;
timeIntervalExpression
: INTERVAL STRING_LITERAL ID_LITERAL
;
// expression
@ -686,10 +823,6 @@ uid
: ID_LITERAL DOT_ID*?
;
plusUid // 匹配 xxx.$xx xx:xxxx 等字符
: (ID_LITERAL | PLUS_ID_LITERAL) (DOT_ID | PLUS_DOT_ID)*?
;
withOption
: WITH tablePropertyList
;

File diff suppressed because one or more lines are too long

View File

@ -262,71 +262,91 @@ ENFORCED=261
METADATA=262
VIRTUAL=263
ZONE=264
STRING=265
ARRAY=266
MAP=267
CHAR=268
VARCHAR=269
BINARY=270
VARBINARY=271
BYTES=272
DECIMAL=273
DEC=274
NUMERIC=275
TINYINT=276
SMALLINT=277
INT=278
INTEGER=279
BIGINT=280
FLOAT=281
DOUBLE=282
DATE=283
TIME=284
TIMESTAMP=285
TIMESTAMP_LTZ=286
MULTISET=287
BOOLEAN=288
RAW=289
ROW=290
NULL=291
DATETIME=292
EQUAL_SYMBOL=293
GREATER_SYMBOL=294
LESS_SYMBOL=295
EXCLAMATION_SYMBOL=296
BIT_NOT_OP=297
BIT_OR_OP=298
BIT_AND_OP=299
BIT_XOR_OP=300
DOT=301
LS_BRACKET=302
RS_BRACKET=303
LR_BRACKET=304
RR_BRACKET=305
COMMA=306
SEMICOLON=307
AT_SIGN=308
SINGLE_QUOTE_SYMB=309
DOUBLE_QUOTE_SYMB=310
REVERSE_QUOTE_SYMB=311
COLON_SYMB=312
ASTERISK_SIGN=313
UNDERLINE_SIGN=314
HYPNEN_SIGN=315
ADD_SIGN=316
PENCENT_SIGN=317
DOUBLE_VERTICAL_SIGN=318
DOUBLE_HYPNEN_SIGN=319
SLASH_SIGN=320
DOT_ID=321
PLUS_DOT_ID=322
STRING_LITERAL=323
DIG_LITERAL=324
REAL_LITERAL=325
BIT_STRING=326
ID_LITERAL=327
PLUS_ID_LITERAL=328
FILE_PATH=329
TUMBLE=265
HOP=266
CUMULATE=267
DESCRIPTOR=268
TIMECOL=269
SIZE=270
OFFSET=271
STEP=272
SLIDE=273
SESSION=274
MATCH_RECOGNIZE=275
MEASURES=276
PATTERN=277
ONE=278
PER=279
KW_SKIP=280
PAST=281
DEFINE=282
STRING=283
ARRAY=284
MAP=285
CHAR=286
VARCHAR=287
BINARY=288
VARBINARY=289
BYTES=290
DECIMAL=291
DEC=292
NUMERIC=293
TINYINT=294
SMALLINT=295
INT=296
INTEGER=297
BIGINT=298
FLOAT=299
DOUBLE=300
DATE=301
TIME=302
TIMESTAMP=303
TIMESTAMP_LTZ=304
MULTISET=305
BOOLEAN=306
RAW=307
ROW=308
NULL=309
DATETIME=310
EQUAL_SYMBOL=311
GREATER_SYMBOL=312
LESS_SYMBOL=313
EXCLAMATION_SYMBOL=314
BIT_NOT_OP=315
BIT_OR_OP=316
BIT_AND_OP=317
BIT_XOR_OP=318
DOT=319
LS_BRACKET=320
RS_BRACKET=321
LR_BRACKET=322
RR_BRACKET=323
LB_BRACKET=324
RB_BRACKET=325
COMMA=326
SEMICOLON=327
AT_SIGN=328
SINGLE_QUOTE_SYMB=329
DOUBLE_QUOTE_SYMB=330
REVERSE_QUOTE_SYMB=331
COLON_SYMB=332
ASTERISK_SIGN=333
UNDERLINE_SIGN=334
HYPNEN_SIGN=335
ADD_SIGN=336
PENCENT_SIGN=337
DOUBLE_VERTICAL_SIGN=338
DOUBLE_HYPNEN_SIGN=339
SLASH_SIGN=340
QUESTION_MARK_SIGN=341
DOT_ID=342
STRING_LITERAL=343
DIG_LITERAL=344
REAL_LITERAL=345
BIT_STRING=346
ID_LITERAL=347
FILE_PATH=348
DOUBLE_ARROW=349
'SELECT'=4
'FROM'=5
'ADD'=6
@ -588,59 +608,81 @@ FILE_PATH=329
'METADATA'=262
'VIRTUAL'=263
'ZONE'=264
'STRING'=265
'ARRAY'=266
'MAP'=267
'CHAR'=268
'VARCHAR'=269
'BINARY'=270
'VARBINARY'=271
'BYTES'=272
'DECIMAL'=273
'DEC'=274
'NUMERIC'=275
'TINYINT'=276
'SMALLINT'=277
'INT'=278
'INTEGER'=279
'BIGINT'=280
'FLOAT'=281
'DOUBLE'=282
'DATE'=283
'TIME'=284
'TIMESTAMP'=285
'TIMESTAMP_LTZ'=286
'MULTISET'=287
'BOOLEAN'=288
'RAW'=289
'ROW'=290
'NULL'=291
'DATETIME'=292
'='=293
'>'=294
'<'=295
'!'=296
'~'=297
'|'=298
'&'=299
'^'=300
'.'=301
'['=302
']'=303
'('=304
')'=305
','=306
';'=307
'@'=308
'\''=309
'"'=310
'`'=311
':'=312
'*'=313
'_'=314
'-'=315
'+'=316
'%'=317
'||'=318
'--'=319
'/'=320
'TUMBLE'=265
'HOP'=266
'CUMULATE'=267
'DESCRIPTOR'=268
'TIMECOL'=269
'SIZE'=270
'OFFSET'=271
'STEP'=272
'SLIDE'=273
'SESSION'=274
'MATCH_RECOGNIZE'=275
'MEASURES'=276
'PATTERN'=277
'ONE'=278
'PER'=279
'SKIP'=280
'PAST'=281
'DEFINE'=282
'STRING'=283
'ARRAY'=284
'MAP'=285
'CHAR'=286
'VARCHAR'=287
'BINARY'=288
'VARBINARY'=289
'BYTES'=290
'DECIMAL'=291
'DEC'=292
'NUMERIC'=293
'TINYINT'=294
'SMALLINT'=295
'INT'=296
'INTEGER'=297
'BIGINT'=298
'FLOAT'=299
'DOUBLE'=300
'DATE'=301
'TIME'=302
'TIMESTAMP'=303
'TIMESTAMP_LTZ'=304
'MULTISET'=305
'BOOLEAN'=306
'RAW'=307
'ROW'=308
'NULL'=309
'DATETIME'=310
'='=311
'>'=312
'<'=313
'!'=314
'~'=315
'|'=316
'&'=317
'^'=318
'.'=319
'['=320
']'=321
'('=322
')'=323
'{'=324
'}'=325
','=326
';'=327
'@'=328
'\''=329
'"'=330
'`'=331
':'=332
'*'=333
'_'=334
'-'=335
'+'=336
'%'=337
'||'=338
'--'=339
'/'=340
'?'=341
'=>'=349

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -262,71 +262,91 @@ ENFORCED=261
METADATA=262
VIRTUAL=263
ZONE=264
STRING=265
ARRAY=266
MAP=267
CHAR=268
VARCHAR=269
BINARY=270
VARBINARY=271
BYTES=272
DECIMAL=273
DEC=274
NUMERIC=275
TINYINT=276
SMALLINT=277
INT=278
INTEGER=279
BIGINT=280
FLOAT=281
DOUBLE=282
DATE=283
TIME=284
TIMESTAMP=285
TIMESTAMP_LTZ=286
MULTISET=287
BOOLEAN=288
RAW=289
ROW=290
NULL=291
DATETIME=292
EQUAL_SYMBOL=293
GREATER_SYMBOL=294
LESS_SYMBOL=295
EXCLAMATION_SYMBOL=296
BIT_NOT_OP=297
BIT_OR_OP=298
BIT_AND_OP=299
BIT_XOR_OP=300
DOT=301
LS_BRACKET=302
RS_BRACKET=303
LR_BRACKET=304
RR_BRACKET=305
COMMA=306
SEMICOLON=307
AT_SIGN=308
SINGLE_QUOTE_SYMB=309
DOUBLE_QUOTE_SYMB=310
REVERSE_QUOTE_SYMB=311
COLON_SYMB=312
ASTERISK_SIGN=313
UNDERLINE_SIGN=314
HYPNEN_SIGN=315
ADD_SIGN=316
PENCENT_SIGN=317
DOUBLE_VERTICAL_SIGN=318
DOUBLE_HYPNEN_SIGN=319
SLASH_SIGN=320
DOT_ID=321
PLUS_DOT_ID=322
STRING_LITERAL=323
DIG_LITERAL=324
REAL_LITERAL=325
BIT_STRING=326
ID_LITERAL=327
PLUS_ID_LITERAL=328
FILE_PATH=329
TUMBLE=265
HOP=266
CUMULATE=267
DESCRIPTOR=268
TIMECOL=269
SIZE=270
OFFSET=271
STEP=272
SLIDE=273
SESSION=274
MATCH_RECOGNIZE=275
MEASURES=276
PATTERN=277
ONE=278
PER=279
KW_SKIP=280
PAST=281
DEFINE=282
STRING=283
ARRAY=284
MAP=285
CHAR=286
VARCHAR=287
BINARY=288
VARBINARY=289
BYTES=290
DECIMAL=291
DEC=292
NUMERIC=293
TINYINT=294
SMALLINT=295
INT=296
INTEGER=297
BIGINT=298
FLOAT=299
DOUBLE=300
DATE=301
TIME=302
TIMESTAMP=303
TIMESTAMP_LTZ=304
MULTISET=305
BOOLEAN=306
RAW=307
ROW=308
NULL=309
DATETIME=310
EQUAL_SYMBOL=311
GREATER_SYMBOL=312
LESS_SYMBOL=313
EXCLAMATION_SYMBOL=314
BIT_NOT_OP=315
BIT_OR_OP=316
BIT_AND_OP=317
BIT_XOR_OP=318
DOT=319
LS_BRACKET=320
RS_BRACKET=321
LR_BRACKET=322
RR_BRACKET=323
LB_BRACKET=324
RB_BRACKET=325
COMMA=326
SEMICOLON=327
AT_SIGN=328
SINGLE_QUOTE_SYMB=329
DOUBLE_QUOTE_SYMB=330
REVERSE_QUOTE_SYMB=331
COLON_SYMB=332
ASTERISK_SIGN=333
UNDERLINE_SIGN=334
HYPNEN_SIGN=335
ADD_SIGN=336
PENCENT_SIGN=337
DOUBLE_VERTICAL_SIGN=338
DOUBLE_HYPNEN_SIGN=339
SLASH_SIGN=340
QUESTION_MARK_SIGN=341
DOT_ID=342
STRING_LITERAL=343
DIG_LITERAL=344
REAL_LITERAL=345
BIT_STRING=346
ID_LITERAL=347
FILE_PATH=348
DOUBLE_ARROW=349
'SELECT'=4
'FROM'=5
'ADD'=6
@ -588,59 +608,81 @@ FILE_PATH=329
'METADATA'=262
'VIRTUAL'=263
'ZONE'=264
'STRING'=265
'ARRAY'=266
'MAP'=267
'CHAR'=268
'VARCHAR'=269
'BINARY'=270
'VARBINARY'=271
'BYTES'=272
'DECIMAL'=273
'DEC'=274
'NUMERIC'=275
'TINYINT'=276
'SMALLINT'=277
'INT'=278
'INTEGER'=279
'BIGINT'=280
'FLOAT'=281
'DOUBLE'=282
'DATE'=283
'TIME'=284
'TIMESTAMP'=285
'TIMESTAMP_LTZ'=286
'MULTISET'=287
'BOOLEAN'=288
'RAW'=289
'ROW'=290
'NULL'=291
'DATETIME'=292
'='=293
'>'=294
'<'=295
'!'=296
'~'=297
'|'=298
'&'=299
'^'=300
'.'=301
'['=302
']'=303
'('=304
')'=305
','=306
';'=307
'@'=308
'\''=309
'"'=310
'`'=311
':'=312
'*'=313
'_'=314
'-'=315
'+'=316
'%'=317
'||'=318
'--'=319
'/'=320
'TUMBLE'=265
'HOP'=266
'CUMULATE'=267
'DESCRIPTOR'=268
'TIMECOL'=269
'SIZE'=270
'OFFSET'=271
'STEP'=272
'SLIDE'=273
'SESSION'=274
'MATCH_RECOGNIZE'=275
'MEASURES'=276
'PATTERN'=277
'ONE'=278
'PER'=279
'SKIP'=280
'PAST'=281
'DEFINE'=282
'STRING'=283
'ARRAY'=284
'MAP'=285
'CHAR'=286
'VARCHAR'=287
'BINARY'=288
'VARBINARY'=289
'BYTES'=290
'DECIMAL'=291
'DEC'=292
'NUMERIC'=293
'TINYINT'=294
'SMALLINT'=295
'INT'=296
'INTEGER'=297
'BIGINT'=298
'FLOAT'=299
'DOUBLE'=300
'DATE'=301
'TIME'=302
'TIMESTAMP'=303
'TIMESTAMP_LTZ'=304
'MULTISET'=305
'BOOLEAN'=306
'RAW'=307
'ROW'=308
'NULL'=309
'DATETIME'=310
'='=311
'>'=312
'<'=313
'!'=314
'~'=315
'|'=316
'&'=317
'^'=318
'.'=319
'['=320
']'=321
'('=322
')'=323
'{'=324
'}'=325
','=326
';'=327
'@'=328
'\''=329
'"'=330
'`'=331
':'=332
'*'=333
'_'=334
'-'=335
'+'=336
'%'=337
'||'=338
'--'=339
'/'=340
'?'=341
'=>'=349

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
import {ParseTreeListener} from "antlr4";
@ -84,11 +84,13 @@ import { ValuesRowDefinitionContext } from "./FlinkSqlParser";
import { InsertMulStatementContext } from "./FlinkSqlParser";
import { QueryStatementContext } from "./FlinkSqlParser";
import { ValuesCaluseContext } from "./FlinkSqlParser";
import { WithClauseContext } from "./FlinkSqlParser";
import { WithItemContext } from "./FlinkSqlParser";
import { WithItemNameContext } from "./FlinkSqlParser";
import { SelectStatementContext } from "./FlinkSqlParser";
import { SelectClauseContext } from "./FlinkSqlParser";
import { ProjectItemDefinitionContext } from "./FlinkSqlParser";
import { OverWindowItemContext } from "./FlinkSqlParser";
import { FromClauseContext } from "./FlinkSqlParser";
import { TableExpressionContext } from "./FlinkSqlParser";
import { TableReferenceContext } from "./FlinkSqlParser";
@ -96,20 +98,42 @@ import { TablePrimaryContext } from "./FlinkSqlParser";
import { TablePathContext } from "./FlinkSqlParser";
import { SystemTimePeriodContext } from "./FlinkSqlParser";
import { DateTimeExpressionContext } from "./FlinkSqlParser";
import { InlineDataValueClauseContext } from "./FlinkSqlParser";
import { WindoTVFClauseContext } from "./FlinkSqlParser";
import { WindowTVFExressionContext } from "./FlinkSqlParser";
import { WindoTVFNameContext } from "./FlinkSqlParser";
import { WindowTVFParamContext } from "./FlinkSqlParser";
import { TimeIntervalParamNameContext } from "./FlinkSqlParser";
import { ColumnDescriptorContext } from "./FlinkSqlParser";
import { JoinConditionContext } from "./FlinkSqlParser";
import { WhereClauseContext } from "./FlinkSqlParser";
import { GroupByClauseContext } from "./FlinkSqlParser";
import { GroupItemDefinitionContext } from "./FlinkSqlParser";
import { GroupingSetsContext } from "./FlinkSqlParser";
import { GroupingSetsNotaionNameContext } from "./FlinkSqlParser";
import { GroupWindowFunctionContext } from "./FlinkSqlParser";
import { GroupWindowFunctionNameContext } from "./FlinkSqlParser";
import { TimeAttrColumnContext } from "./FlinkSqlParser";
import { HavingClauseContext } from "./FlinkSqlParser";
import { OrderByCaluseContext } from "./FlinkSqlParser";
import { OrderItemDefitionContext } from "./FlinkSqlParser";
import { LimitClauseContext } from "./FlinkSqlParser";
import { WindowClauseContext } from "./FlinkSqlParser";
import { NamedWindowContext } from "./FlinkSqlParser";
import { WindowSpecContext } from "./FlinkSqlParser";
import { SortItemContext } from "./FlinkSqlParser";
import { MatchRecognizeClauseContext } from "./FlinkSqlParser";
import { OrderByCaluseContext } from "./FlinkSqlParser";
import { OrderItemDefitionContext } from "./FlinkSqlParser";
import { LimitClauseContext } from "./FlinkSqlParser";
import { PartitionByClauseContext } from "./FlinkSqlParser";
import { QuantifiersContext } from "./FlinkSqlParser";
import { MeasuresClauseContext } from "./FlinkSqlParser";
import { PatternDefinationContext } from "./FlinkSqlParser";
import { PatternVariableContext } from "./FlinkSqlParser";
import { OutputModeContext } from "./FlinkSqlParser";
import { AfterMatchStrategyContext } from "./FlinkSqlParser";
import { PatternVariablesDefinationContext } from "./FlinkSqlParser";
import { WindowFrameContext } from "./FlinkSqlParser";
import { FrameBoundContext } from "./FlinkSqlParser";
import { WithinClauseContext } from "./FlinkSqlParser";
import { TimeIntervalExpressionContext } from "./FlinkSqlParser";
import { ExpressionContext } from "./FlinkSqlParser";
import { LogicalNotContext } from "./FlinkSqlParser";
import { PredicatedContext } from "./FlinkSqlParser";
@ -162,7 +186,6 @@ import { QuotedIdentifierContext } from "./FlinkSqlParser";
import { WhenClauseContext } from "./FlinkSqlParser";
import { UidListContext } from "./FlinkSqlParser";
import { UidContext } from "./FlinkSqlParser";
import { PlusUidContext } from "./FlinkSqlParser";
import { WithOptionContext } from "./FlinkSqlParser";
import { IfNotExistsContext } from "./FlinkSqlParser";
import { IfExistsContext } from "./FlinkSqlParser";
@ -1005,6 +1028,16 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitValuesCaluse?: (ctx: ValuesCaluseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.withClause`.
* @param ctx the parse tree
*/
enterWithClause?: (ctx: WithClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.withClause`.
* @param ctx the parse tree
*/
exitWithClause?: (ctx: WithClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.withItem`.
* @param ctx the parse tree
@ -1055,6 +1088,16 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitProjectItemDefinition?: (ctx: ProjectItemDefinitionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.overWindowItem`.
* @param ctx the parse tree
*/
enterOverWindowItem?: (ctx: OverWindowItemContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.overWindowItem`.
* @param ctx the parse tree
*/
exitOverWindowItem?: (ctx: OverWindowItemContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.fromClause`.
* @param ctx the parse tree
@ -1125,6 +1168,76 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitDateTimeExpression?: (ctx: DateTimeExpressionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.inlineDataValueClause`.
* @param ctx the parse tree
*/
enterInlineDataValueClause?: (ctx: InlineDataValueClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.inlineDataValueClause`.
* @param ctx the parse tree
*/
exitInlineDataValueClause?: (ctx: InlineDataValueClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.windoTVFClause`.
* @param ctx the parse tree
*/
enterWindoTVFClause?: (ctx: WindoTVFClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.windoTVFClause`.
* @param ctx the parse tree
*/
exitWindoTVFClause?: (ctx: WindoTVFClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.windowTVFExression`.
* @param ctx the parse tree
*/
enterWindowTVFExression?: (ctx: WindowTVFExressionContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.windowTVFExression`.
* @param ctx the parse tree
*/
exitWindowTVFExression?: (ctx: WindowTVFExressionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.windoTVFName`.
* @param ctx the parse tree
*/
enterWindoTVFName?: (ctx: WindoTVFNameContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.windoTVFName`.
* @param ctx the parse tree
*/
exitWindoTVFName?: (ctx: WindoTVFNameContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.windowTVFParam`.
* @param ctx the parse tree
*/
enterWindowTVFParam?: (ctx: WindowTVFParamContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.windowTVFParam`.
* @param ctx the parse tree
*/
exitWindowTVFParam?: (ctx: WindowTVFParamContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.timeIntervalParamName`.
* @param ctx the parse tree
*/
enterTimeIntervalParamName?: (ctx: TimeIntervalParamNameContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.timeIntervalParamName`.
* @param ctx the parse tree
*/
exitTimeIntervalParamName?: (ctx: TimeIntervalParamNameContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.columnDescriptor`.
* @param ctx the parse tree
*/
enterColumnDescriptor?: (ctx: ColumnDescriptorContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.columnDescriptor`.
* @param ctx the parse tree
*/
exitColumnDescriptor?: (ctx: ColumnDescriptorContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.joinCondition`.
* @param ctx the parse tree
@ -1165,6 +1278,56 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitGroupItemDefinition?: (ctx: GroupItemDefinitionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.groupingSets`.
* @param ctx the parse tree
*/
enterGroupingSets?: (ctx: GroupingSetsContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.groupingSets`.
* @param ctx the parse tree
*/
exitGroupingSets?: (ctx: GroupingSetsContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.groupingSetsNotaionName`.
* @param ctx the parse tree
*/
enterGroupingSetsNotaionName?: (ctx: GroupingSetsNotaionNameContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.groupingSetsNotaionName`.
* @param ctx the parse tree
*/
exitGroupingSetsNotaionName?: (ctx: GroupingSetsNotaionNameContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.groupWindowFunction`.
* @param ctx the parse tree
*/
enterGroupWindowFunction?: (ctx: GroupWindowFunctionContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.groupWindowFunction`.
* @param ctx the parse tree
*/
exitGroupWindowFunction?: (ctx: GroupWindowFunctionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.groupWindowFunctionName`.
* @param ctx the parse tree
*/
enterGroupWindowFunctionName?: (ctx: GroupWindowFunctionNameContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.groupWindowFunctionName`.
* @param ctx the parse tree
*/
exitGroupWindowFunctionName?: (ctx: GroupWindowFunctionNameContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.timeAttrColumn`.
* @param ctx the parse tree
*/
enterTimeAttrColumn?: (ctx: TimeAttrColumnContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.timeAttrColumn`.
* @param ctx the parse tree
*/
exitTimeAttrColumn?: (ctx: TimeAttrColumnContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.havingClause`.
* @param ctx the parse tree
@ -1175,36 +1338,6 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitHavingClause?: (ctx: HavingClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.orderByCaluse`.
* @param ctx the parse tree
*/
enterOrderByCaluse?: (ctx: OrderByCaluseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.orderByCaluse`.
* @param ctx the parse tree
*/
exitOrderByCaluse?: (ctx: OrderByCaluseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.orderItemDefition`.
* @param ctx the parse tree
*/
enterOrderItemDefition?: (ctx: OrderItemDefitionContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.orderItemDefition`.
* @param ctx the parse tree
*/
exitOrderItemDefition?: (ctx: OrderItemDefitionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.limitClause`.
* @param ctx the parse tree
*/
enterLimitClause?: (ctx: LimitClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.limitClause`.
* @param ctx the parse tree
*/
exitLimitClause?: (ctx: LimitClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.windowClause`.
* @param ctx the parse tree
@ -1236,15 +1369,125 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
*/
exitWindowSpec?: (ctx: WindowSpecContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.sortItem`.
* Enter a parse tree produced by `FlinkSqlParser.matchRecognizeClause`.
* @param ctx the parse tree
*/
enterSortItem?: (ctx: SortItemContext) => void;
enterMatchRecognizeClause?: (ctx: MatchRecognizeClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.sortItem`.
* Exit a parse tree produced by `FlinkSqlParser.matchRecognizeClause`.
* @param ctx the parse tree
*/
exitSortItem?: (ctx: SortItemContext) => void;
exitMatchRecognizeClause?: (ctx: MatchRecognizeClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.orderByCaluse`.
* @param ctx the parse tree
*/
enterOrderByCaluse?: (ctx: OrderByCaluseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.orderByCaluse`.
* @param ctx the parse tree
*/
exitOrderByCaluse?: (ctx: OrderByCaluseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.orderItemDefition`.
* @param ctx the parse tree
*/
enterOrderItemDefition?: (ctx: OrderItemDefitionContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.orderItemDefition`.
* @param ctx the parse tree
*/
exitOrderItemDefition?: (ctx: OrderItemDefitionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.limitClause`.
* @param ctx the parse tree
*/
enterLimitClause?: (ctx: LimitClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.limitClause`.
* @param ctx the parse tree
*/
exitLimitClause?: (ctx: LimitClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.partitionByClause`.
* @param ctx the parse tree
*/
enterPartitionByClause?: (ctx: PartitionByClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.partitionByClause`.
* @param ctx the parse tree
*/
exitPartitionByClause?: (ctx: PartitionByClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.quantifiers`.
* @param ctx the parse tree
*/
enterQuantifiers?: (ctx: QuantifiersContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.quantifiers`.
* @param ctx the parse tree
*/
exitQuantifiers?: (ctx: QuantifiersContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.measuresClause`.
* @param ctx the parse tree
*/
enterMeasuresClause?: (ctx: MeasuresClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.measuresClause`.
* @param ctx the parse tree
*/
exitMeasuresClause?: (ctx: MeasuresClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.patternDefination`.
* @param ctx the parse tree
*/
enterPatternDefination?: (ctx: PatternDefinationContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.patternDefination`.
* @param ctx the parse tree
*/
exitPatternDefination?: (ctx: PatternDefinationContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.patternVariable`.
* @param ctx the parse tree
*/
enterPatternVariable?: (ctx: PatternVariableContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.patternVariable`.
* @param ctx the parse tree
*/
exitPatternVariable?: (ctx: PatternVariableContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.outputMode`.
* @param ctx the parse tree
*/
enterOutputMode?: (ctx: OutputModeContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.outputMode`.
* @param ctx the parse tree
*/
exitOutputMode?: (ctx: OutputModeContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.afterMatchStrategy`.
* @param ctx the parse tree
*/
enterAfterMatchStrategy?: (ctx: AfterMatchStrategyContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.afterMatchStrategy`.
* @param ctx the parse tree
*/
exitAfterMatchStrategy?: (ctx: AfterMatchStrategyContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.patternVariablesDefination`.
* @param ctx the parse tree
*/
enterPatternVariablesDefination?: (ctx: PatternVariablesDefinationContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.patternVariablesDefination`.
* @param ctx the parse tree
*/
exitPatternVariablesDefination?: (ctx: PatternVariablesDefinationContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.windowFrame`.
* @param ctx the parse tree
@ -1265,6 +1508,26 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitFrameBound?: (ctx: FrameBoundContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.withinClause`.
* @param ctx the parse tree
*/
enterWithinClause?: (ctx: WithinClauseContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.withinClause`.
* @param ctx the parse tree
*/
exitWithinClause?: (ctx: WithinClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.timeIntervalExpression`.
* @param ctx the parse tree
*/
enterTimeIntervalExpression?: (ctx: TimeIntervalExpressionContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.timeIntervalExpression`.
* @param ctx the parse tree
*/
exitTimeIntervalExpression?: (ctx: TimeIntervalExpressionContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.expression`.
* @param ctx the parse tree
@ -1841,16 +2104,6 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
exitUid?: (ctx: UidContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.plusUid`.
* @param ctx the parse tree
*/
enterPlusUid?: (ctx: PlusUidContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.plusUid`.
* @param ctx the parse tree
*/
exitPlusUid?: (ctx: PlusUidContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.withOption`.
* @param ctx the parse tree

View File

@ -1,4 +1,4 @@
// Generated from /Users/ziv/github.com/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
// Generated from /Users/hayden/Desktop/dt-works/dt-sql-parser/src/grammar/flinksql/FlinkSqlParser.g4 by ANTLR 4.12.0
import {ParseTreeVisitor} from 'antlr4';
@ -84,11 +84,13 @@ import { ValuesRowDefinitionContext } from "./FlinkSqlParser";
import { InsertMulStatementContext } from "./FlinkSqlParser";
import { QueryStatementContext } from "./FlinkSqlParser";
import { ValuesCaluseContext } from "./FlinkSqlParser";
import { WithClauseContext } from "./FlinkSqlParser";
import { WithItemContext } from "./FlinkSqlParser";
import { WithItemNameContext } from "./FlinkSqlParser";
import { SelectStatementContext } from "./FlinkSqlParser";
import { SelectClauseContext } from "./FlinkSqlParser";
import { ProjectItemDefinitionContext } from "./FlinkSqlParser";
import { OverWindowItemContext } from "./FlinkSqlParser";
import { FromClauseContext } from "./FlinkSqlParser";
import { TableExpressionContext } from "./FlinkSqlParser";
import { TableReferenceContext } from "./FlinkSqlParser";
@ -96,20 +98,42 @@ import { TablePrimaryContext } from "./FlinkSqlParser";
import { TablePathContext } from "./FlinkSqlParser";
import { SystemTimePeriodContext } from "./FlinkSqlParser";
import { DateTimeExpressionContext } from "./FlinkSqlParser";
import { InlineDataValueClauseContext } from "./FlinkSqlParser";
import { WindoTVFClauseContext } from "./FlinkSqlParser";
import { WindowTVFExressionContext } from "./FlinkSqlParser";
import { WindoTVFNameContext } from "./FlinkSqlParser";
import { WindowTVFParamContext } from "./FlinkSqlParser";
import { TimeIntervalParamNameContext } from "./FlinkSqlParser";
import { ColumnDescriptorContext } from "./FlinkSqlParser";
import { JoinConditionContext } from "./FlinkSqlParser";
import { WhereClauseContext } from "./FlinkSqlParser";
import { GroupByClauseContext } from "./FlinkSqlParser";
import { GroupItemDefinitionContext } from "./FlinkSqlParser";
import { GroupingSetsContext } from "./FlinkSqlParser";
import { GroupingSetsNotaionNameContext } from "./FlinkSqlParser";
import { GroupWindowFunctionContext } from "./FlinkSqlParser";
import { GroupWindowFunctionNameContext } from "./FlinkSqlParser";
import { TimeAttrColumnContext } from "./FlinkSqlParser";
import { HavingClauseContext } from "./FlinkSqlParser";
import { OrderByCaluseContext } from "./FlinkSqlParser";
import { OrderItemDefitionContext } from "./FlinkSqlParser";
import { LimitClauseContext } from "./FlinkSqlParser";
import { WindowClauseContext } from "./FlinkSqlParser";
import { NamedWindowContext } from "./FlinkSqlParser";
import { WindowSpecContext } from "./FlinkSqlParser";
import { SortItemContext } from "./FlinkSqlParser";
import { MatchRecognizeClauseContext } from "./FlinkSqlParser";
import { OrderByCaluseContext } from "./FlinkSqlParser";
import { OrderItemDefitionContext } from "./FlinkSqlParser";
import { LimitClauseContext } from "./FlinkSqlParser";
import { PartitionByClauseContext } from "./FlinkSqlParser";
import { QuantifiersContext } from "./FlinkSqlParser";
import { MeasuresClauseContext } from "./FlinkSqlParser";
import { PatternDefinationContext } from "./FlinkSqlParser";
import { PatternVariableContext } from "./FlinkSqlParser";
import { OutputModeContext } from "./FlinkSqlParser";
import { AfterMatchStrategyContext } from "./FlinkSqlParser";
import { PatternVariablesDefinationContext } from "./FlinkSqlParser";
import { WindowFrameContext } from "./FlinkSqlParser";
import { FrameBoundContext } from "./FlinkSqlParser";
import { WithinClauseContext } from "./FlinkSqlParser";
import { TimeIntervalExpressionContext } from "./FlinkSqlParser";
import { ExpressionContext } from "./FlinkSqlParser";
import { LogicalNotContext } from "./FlinkSqlParser";
import { PredicatedContext } from "./FlinkSqlParser";
@ -162,7 +186,6 @@ import { QuotedIdentifierContext } from "./FlinkSqlParser";
import { WhenClauseContext } from "./FlinkSqlParser";
import { UidListContext } from "./FlinkSqlParser";
import { UidContext } from "./FlinkSqlParser";
import { PlusUidContext } from "./FlinkSqlParser";
import { WithOptionContext } from "./FlinkSqlParser";
import { IfNotExistsContext } from "./FlinkSqlParser";
import { IfExistsContext } from "./FlinkSqlParser";
@ -682,6 +705,12 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result
*/
visitValuesCaluse?: (ctx: ValuesCaluseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.withClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitWithClause?: (ctx: WithClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.withItem`.
* @param ctx the parse tree
@ -712,6 +741,12 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result
*/
visitProjectItemDefinition?: (ctx: ProjectItemDefinitionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.overWindowItem`.
* @param ctx the parse tree
* @return the visitor result
*/
visitOverWindowItem?: (ctx: OverWindowItemContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.fromClause`.
* @param ctx the parse tree
@ -754,6 +789,48 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result
*/
visitDateTimeExpression?: (ctx: DateTimeExpressionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.inlineDataValueClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitInlineDataValueClause?: (ctx: InlineDataValueClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.windoTVFClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitWindoTVFClause?: (ctx: WindoTVFClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.windowTVFExression`.
* @param ctx the parse tree
* @return the visitor result
*/
visitWindowTVFExression?: (ctx: WindowTVFExressionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.windoTVFName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitWindoTVFName?: (ctx: WindoTVFNameContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.windowTVFParam`.
* @param ctx the parse tree
* @return the visitor result
*/
visitWindowTVFParam?: (ctx: WindowTVFParamContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.timeIntervalParamName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitTimeIntervalParamName?: (ctx: TimeIntervalParamNameContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.columnDescriptor`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumnDescriptor?: (ctx: ColumnDescriptorContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.joinCondition`.
* @param ctx the parse tree
@ -778,30 +855,42 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result
*/
visitGroupItemDefinition?: (ctx: GroupItemDefinitionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.groupingSets`.
* @param ctx the parse tree
* @return the visitor result
*/
visitGroupingSets?: (ctx: GroupingSetsContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.groupingSetsNotaionName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitGroupingSetsNotaionName?: (ctx: GroupingSetsNotaionNameContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.groupWindowFunction`.
* @param ctx the parse tree
* @return the visitor result
*/
visitGroupWindowFunction?: (ctx: GroupWindowFunctionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.groupWindowFunctionName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitGroupWindowFunctionName?: (ctx: GroupWindowFunctionNameContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.timeAttrColumn`.
* @param ctx the parse tree
* @return the visitor result
*/
visitTimeAttrColumn?: (ctx: TimeAttrColumnContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.havingClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitHavingClause?: (ctx: HavingClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.orderByCaluse`.
* @param ctx the parse tree
* @return the visitor result
*/
visitOrderByCaluse?: (ctx: OrderByCaluseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.orderItemDefition`.
* @param ctx the parse tree
* @return the visitor result
*/
visitOrderItemDefition?: (ctx: OrderItemDefitionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.limitClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitLimitClause?: (ctx: LimitClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.windowClause`.
* @param ctx the parse tree
@ -821,11 +910,77 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
*/
visitWindowSpec?: (ctx: WindowSpecContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.sortItem`.
* Visit a parse tree produced by `FlinkSqlParser.matchRecognizeClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitSortItem?: (ctx: SortItemContext) => Result;
visitMatchRecognizeClause?: (ctx: MatchRecognizeClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.orderByCaluse`.
* @param ctx the parse tree
* @return the visitor result
*/
visitOrderByCaluse?: (ctx: OrderByCaluseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.orderItemDefition`.
* @param ctx the parse tree
* @return the visitor result
*/
visitOrderItemDefition?: (ctx: OrderItemDefitionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.limitClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitLimitClause?: (ctx: LimitClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.partitionByClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPartitionByClause?: (ctx: PartitionByClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.quantifiers`.
* @param ctx the parse tree
* @return the visitor result
*/
visitQuantifiers?: (ctx: QuantifiersContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.measuresClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitMeasuresClause?: (ctx: MeasuresClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.patternDefination`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPatternDefination?: (ctx: PatternDefinationContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.patternVariable`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPatternVariable?: (ctx: PatternVariableContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.outputMode`.
* @param ctx the parse tree
* @return the visitor result
*/
visitOutputMode?: (ctx: OutputModeContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.afterMatchStrategy`.
* @param ctx the parse tree
* @return the visitor result
*/
visitAfterMatchStrategy?: (ctx: AfterMatchStrategyContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.patternVariablesDefination`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPatternVariablesDefination?: (ctx: PatternVariablesDefinationContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.windowFrame`.
* @param ctx the parse tree
@ -838,6 +993,18 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result
*/
visitFrameBound?: (ctx: FrameBoundContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.withinClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitWithinClause?: (ctx: WithinClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.timeIntervalExpression`.
* @param ctx the parse tree
* @return the visitor result
*/
visitTimeIntervalExpression?: (ctx: TimeIntervalExpressionContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.expression`.
* @param ctx the parse tree
@ -1178,12 +1345,6 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result
*/
visitUid?: (ctx: UidContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.plusUid`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPlusUid?: (ctx: PlusUidContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.withOption`.
* @param ctx the parse tree

View File

@ -0,0 +1,13 @@
SELECT * FROM Orders;
SELECT order_id, price + tax FROM Orders;
SELECT order_id, price FROM (VALUES (1, 2.0), (2, 3.1)) AS t (order_id, price);
SELECT price + tax FROM Orders WHERE id = 10;
SELECT PRETTY_PRINT(order_id) FROM Orders;
SELECT * FROM Orders ORDER BY order_time, order_id;
SELECT * FROM Orders ORDER BY orderTime LIMIT 3;

View File

@ -0,0 +1,122 @@
-- Window TVF Aggregation
SELECT
window_start,
window_end,
supplier_id,
SUM(price) as price
FROM TABLE(
TUMBLE(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '10' MINUTES))
GROUP BY window_start, window_end, GROUPING SETS ((supplier_id), ());
SELECT
window_start,
window_end,
supplier_id,
SUM(price) as price
FROM TABLE(
TUMBLE(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '10' MINUTES))
GROUP BY window_start, window_end, ROLLUP (supplier_id);
SELECT
window_start,
window_end,
item, supplier_id,
SUM(price) as price
FROM TABLE(
TUMBLE(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '10' MINUTES))
GROUP BY window_start, window_end, CUBE (supplier_id, item);
-- GROUPING SETS
SELECT
window_start,
window_end,
supplier_id,
SUM(price) as price
FROM TABLE(
TUMBLE(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '10' MINUTES))
GROUP BY
window_start,
window_end,
GROUPING SETS ((supplier_id), ());
SELECT
window_start,
window_end,
supplier_id,
SUM(price) as price
FROM TABLE(
TUMBLE(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '10' MINUTES))
GROUP BY
window_start,
window_end,
ROLLUP (supplier_id);
SELECT
window_start,
window_end,
item,
supplier_id,
SUM(price) as price
FROM TABLE(
TUMBLE(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '10' MINUTES))
GROUP BY
window_start,
window_end,
CUBE (supplier_id, item);
-- Group Window Aggregation
SELECT
user,
TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart,
SUM(amount) FROM Orders
GROUP BY
TUMBLE(order_time, INTERVAL '1' DAY),
user;
SELECT
user,
TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart,
SUM(amount) FROM Orders
GROUP BY
HOP(order_time, INTERVAL '1' DAY),
user;
SELECT
user,
TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart,
SUM(amount) FROM Orders
GROUP BY
SESSION(order_time, INTERVAL '1' DAY),
user;
-- Having
SELECT SUM(amount)
FROM Orders
GROUP BY users
HAVING SUM(amount) > 50;
-- Over Aggregation
SELECT order_id, order_time, amount,
SUM(amount) OVER (
PARTITION BY product
ORDER BY order_time
RANGE BETWEEN INTERVAL '1' HOUR PRECEDING AND CURRENT ROW
) AS one_hour_prod_amount_sum
FROM Orders;
SELECT product, order_time, amount,
SUM(amount) OVER (
PARTITION BY product
ORDER BY order_time
ROWS BETWEEN 5 PRECEDING AND CURRENT ROW
) AS one_hour_prod_amount_sum
FROM source_table;
SELECT order_id, order_time, amount,
SUM(amount) OVER w AS sum_amount,
AVG(amount) OVER w AS avg_amount
FROM Orders
WINDOW w AS (
PARTITION BY product
ORDER BY order_time
RANGE BETWEEN INTERVAL '1' HOUR PRECEDING AND CURRENT ROW);

View File

@ -0,0 +1,7 @@
SELECT DISTINCT order_id, price + tax FROM Orders;
SELECT DISTINCT order_id, price FROM (VALUES (1, 2.0), (2, 3.1)) AS t (order_id, price);
SELECT DISTINCT price + tax FROM Orders WHERE id = 10;
SELECT DISTINCT PRETTY_PRINT(order_id) FROM Orders;

View File

@ -0,0 +1,128 @@
-- INNER Equi-JOIN
SELECT *
FROM Orders
INNER JOIN Product
ON Orders.product_id = Product.id;
-- OUTER Equi-JOIN
SELECT *
FROM Orders
LEFT JOIN Product
ON Orders.product_id = Product.id;
SELECT *
FROM Orders
RIGHT JOIN Product
ON Orders.product_id = Product.id;
SELECT *
FROM Orders
FULL OUTER JOIN Product
ON Orders.product_id = Product.id;
-- Interval Joins
SELECT *
FROM Orders o, Shipments s
WHERE o.id = s.order_id
AND o.order_time BETWEEN s.ship_time - INTERVAL '4' HOUR AND s.ship_time;
SELECT *
FROM Orders o, Shipments s
WHERE o.id = s.order_id
AND o.order_time = s.ship_time; -- ltime = rtime
SELECT *
FROM Orders o, Shipments s
WHERE o.id = s.order_id
AND o.order_time >= s.ship_time -- ltime >= rtime AND ltime < rtime + INTERVAL '10' MINUTE
AND o.order_time < s.ship_time + INTERVAL '10' MINUTE;
-- Temporal Joins
SELECT
order_id,
price,
orders.currency,
conversion_rate,
order_time
FROM orders
LEFT JOIN currency_rates FOR SYSTEM_TIME AS OF orders.order_time
ON orders.currency = currency_rates.currency;
SELECT
o_amount, r_rate
FROM
Orders,
LATERAL TABLE (Rates(o_proctime))
WHERE
r_currency = o_currency;
-- Lookup Join
SELECT o.order_id, o.total, c.country, c.zip
FROM Orders AS o
JOIN Customers FOR SYSTEM_TIME AS OF o.proc_time AS c
ON o.customer_id = c.id;
-- Table Function INNER JOIN
SELECT order_id, res
FROM Orders,
LATERAL TABLE(table_func(order_id)) t(res);
-- Table Function LEFT OUTER JOIN
SELECT order_id, res
FROM Orders
LEFT OUTER JOIN LATERAL TABLE(table_func(order_id)) t(res)
ON TRUE;
-- Cross Join
SELECT order_id, tag
FROM Orders CROSS JOIN UNNEST(tags) AS t (tag)
-- FULL OUTER Window Join
SELECT L.num as L_Num, L.id as L_Id, R.num as R_Num, R.id as R_Id,
COALESCE(L.window_start, R.window_start) as window_start,
COALESCE(L.window_end, R.window_end) as window_end
FROM (
SELECT * FROM TABLE(TUMBLE(TABLE LeftTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) L
FULL JOIN (
SELECT * FROM TABLE(TUMBLE(TABLE RightTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) R
ON L.num = R.num AND L.window_start = R.window_start AND L.window_end = R.window_end;
-- Semi Window Joins
SELECT *
FROM (
SELECT * FROM TABLE(TUMBLE(TABLE LeftTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) L WHERE L.num IN (
SELECT num FROM (
SELECT * FROM TABLE(TUMBLE(TABLE RightTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) R WHERE L.window_start = R.window_start AND L.window_end = R.window_end
);
SELECT *
FROM (
SELECT * FROM TABLE(TUMBLE(TABLE LeftTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) L WHERE L.num IN (
SELECT num FROM (
SELECT * FROM TABLE(TUMBLE(TABLE RightTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) R WHERE L.window_start = R.window_start AND L.window_end = R.window_end
);
-- Anti Window Joins
SELECT *
FROM (
SELECT * FROM TABLE(TUMBLE(TABLE LeftTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) L WHERE L.num NOT IN (
SELECT num FROM (
SELECT * FROM TABLE(TUMBLE(TABLE RightTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) R WHERE L.window_start = R.window_start AND L.window_end = R.window_end
);
SELECT *
FROM (
SELECT * FROM TABLE(TUMBLE(TABLE LeftTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) L WHERE NOT EXISTS (
SELECT * FROM (
SELECT * FROM TABLE(TUMBLE(TABLE RightTable, DESCRIPTOR(row_time), INTERVAL '5' MINUTES))
) R WHERE L.num = R.num AND L.window_start = R.window_start AND L.window_end = R.window_end
);

View File

@ -0,0 +1,165 @@
-- basic pattern recognition
SELECT T.aid, T.bid, T.cid
FROM MyTable
MATCH_RECOGNIZE (
PARTITION BY userid
ORDER BY proctime
MEASURES
A.id AS aid,
B.id AS bid,
C.id AS cid
PATTERN (A B C)
DEFINE
A AS name = 'a',
B AS name = 'b',
C AS name = 'c'
) AS T;
SELECT *
FROM Ticker
MATCH_RECOGNIZE (
PARTITION BY symbol
ORDER BY rowtime
MEASURES
START_ROW.rowtime AS start_tstamp,
_LAST(PRICE_DOWN.rowtime) AS bottom_tstamp,
_LAST(PRICE_UP.rowtime) AS end_tstamp
ONE ROW PER MATCH
AFTER MATCH SKIP TO LAST PRICE_UP
PATTERN (START_ROW PRICE_DOWN+ PRICE_UP)
DEFINE
PRICE_DOWN AS
(_LAST(PRICE_DOWN.price, 1) IS NULL AND PRICE_DOWN.price < START_ROW.price) OR
PRICE_DOWN.price < _LAST(PRICE_DOWN.price, 1),
PRICE_UP AS
PRICE_UP.price > _LAST(PRICE_DOWN.price, 1)
) MR;
-- Measures Aggregations
SELECT *
FROM Ticker
MATCH_RECOGNIZE (
PARTITION BY symbol
ORDER BY rowtime
MEASURES
FIRST(A.rowtime) AS start_tstamp,
_LAST(A.rowtime) AS end_tstamp,
AVG(A.price) AS avgPrice
ONE ROW PER MATCH
AFTER MATCH SKIP PAST LAST ROW
PATTERN (A+ B)
DEFINE
A AS AVG(A.price) < 15
) MR;
-- Define a Pattern
SELECT *
FROM Ticker
MATCH_RECOGNIZE(
PARTITION BY symbol
ORDER BY rowtime
MEASURES
C.price AS lastPrice
ONE ROW PER MATCH
AFTER MATCH SKIP PAST LAST ROW
PATTERN (A+ B* C? D{1,} E{,5} F{1,5})
DEFINE
A AS A.price > 10,
B AS B.price < 15,
C AS C.price > 12
);
-- Time constraint
SELECT *
FROM Ticker
MATCH_RECOGNIZE(
PARTITION BY symbol
ORDER BY rowtime
MEASURES
C.rowtime AS dropTime,
A.price - C.price AS dropDiff
ONE ROW PER MATCH
AFTER MATCH SKIP PAST LAST ROW
PATTERN (A B* C) WITHIN INTERVAL '1' HOUR
DEFINE
B AS B.price > A.price - 10,
C AS C.price < A.price - 10
);
-- Output Mode
SELECT *
FROM Ticker
MATCH_RECOGNIZE(
PARTITION BY symbol
ORDER BY rowtime
MEASURES
FIRST(A.price) AS startPrice,
_LAST(A.price) AS topPrice,
B.price AS lastPrice
ONE ROW PER MATCH
PATTERN (A+ B)
DEFINE
A AS _LAST(A.price, 1) IS NULL OR A.price > _LAST(A.price, 1),
B AS B.price < _LAST(A.price)
);
SELECT *
FROM Ticker
MATCH_RECOGNIZE(
PARTITION BY symbol
ORDER BY rowtime
MEASURES
FIRST(A.price) AS startPrice,
_LAST(A.price) AS topPrice,
B.price AS lastPrice
ALL ROWS PER MATCH
PATTERN (A+ B)
DEFINE
A AS _LAST(A.price, 1) IS NULL OR A.price > _LAST(A.price, 1),
B AS B.price < _LAST(A.price)
);
-- After Match Strategy
SELECT *
FROM Ticker
MATCH_RECOGNIZE (
PARTITION BY symbol
ORDER BY rowtime
MEASURES
FIRST(A.rowtime) AS start_tstamp
ONE ROW PER MATCH
AFTER MATCH SKIP TO NEXT ROW
PATTERN (A+ B)
DEFINE
A AS AVG(A.price) < 15
) MR;
SELECT *
FROM Ticker
MATCH_RECOGNIZE (
PARTITION BY symbol
ORDER BY rowtime
MEASURES
FIRST(A.rowtime) AS start_tstamp
ONE ROW PER MATCH
AFTER MATCH SKIP TO LAST A
PATTERN (A+ B)
DEFINE
A AS AVG(A.price) < 15
) MR;
SELECT *
FROM Ticker
MATCH_RECOGNIZE (
PARTITION BY symbol
ORDER BY rowtime
MEASURES
FIRST(A.rowtime) AS start_tstamp
ONE ROW PER MATCH
AFTER MATCH SKIP TO FIRST A
PATTERN (A+ B)
DEFINE
A AS AVG(A.price) < 15
) MR;

View File

@ -0,0 +1,28 @@
-- UNION
(SELECT s FROM t1) UNION (SELECT s FROM t2);
(SELECT s FROM t1) UNION ALL (SELECT s FROM t2);
-- INTERSECT
(SELECT s FROM t1) INTERSECT (SELECT s FROM t2);
(SELECT s FROM t1) INTERSECT ALL (SELECT s FROM t2);
-- EXPECT
(SELECT s FROM t1) EXCEPT (SELECT s FROM t2);
(SELECT s FROM t1) EXCEPT ALL (SELECT s FROM t2);
-- IN
SELECT user, amount
FROM Orders
WHERE product IN (
SELECT product FROM NewProducts
)
-- EXISTS
SELECT user, amount
FROM Orders
WHERE product EXISTS (
SELECT product FROM NewProducts
)

View File

@ -0,0 +1,52 @@
SELECT * FROM TABLE(
TUMBLE(
DATA => TABLE Bid,
TIMECOL => DESCRIPTOR(bidtime),
SIZE => INTERVAL '10' MINUTES
)
);
SELECT window_start,
window_end,
SUM(price)
FROM TABLE(
TUMBLE(
TABLE Bid,
DESCRIPTOR(bidtime),
INTERVAL '10' MINUTES
)
)
GROUP BY window_start, window_end;
SELECT * FROM TABLE(
HOP(TABLE Bid, DESCRIPTOR(bidtime), INTERVAL '5' MINUTES, INTERVAL '10' MINUTES));
SELECT * FROM TABLE(
HOP(
DATA => TABLE Bid,
TIMECOL => DESCRIPTOR(bidtime),
SLIDE => INTERVAL '5' MINUTES,
SIZE => INTERVAL '10' MINUTES
)
);
SELECT * FROM TABLE(
CUMULATE(
DATA => TABLE Bid,
TIMECOL => DESCRIPTOR(bidtime),
STEP => INTERVAL '2' MINUTES,
SIZE => INTERVAL '10' MINUTES
)
);
SELECT window_start,
window_end,
SUM(price)
FROM TABLE(
CUMULATE(
TABLE Bid,
DESCRIPTOR(bidtime),
INTERVAL '2' MINUTES,
INTERVAL '10' MINUTES
))
GROUP BY window_start, window_end;

View File

@ -0,0 +1,7 @@
WITH orders_with_total AS (
SELECT order_id, price + tax AS total
FROM Orders
)
SELECT order_id, SUM(total)
FROM orders_with_total
GROUP BY order_id;

View File

@ -0,0 +1,82 @@
import FlinkSQL from "../../../../src/parser/flinksql";
import { readSQL } from "../../../helper";
const parser = new FlinkSQL();
const features = {
base: readSQL(__dirname, "select.sql"),
withClause: readSQL(__dirname, "selectWithClause.sql"),
distinct: readSQL(__dirname, "selectDistinct.sql"),
windowTVF: readSQL(__dirname, "selectWindowTVF.sql"),
aggregation: readSQL(__dirname, "selectAggregation.sql"),
join: readSQL(__dirname, "selectJoin.sql"),
setOperation: readSQL(__dirname, "selectSetOperations.sql"),
pattern: readSQL(__dirname, "selectPatternRecognition.sql")
};
describe("FlinkSQL Query Statement Tests", () => {
describe("Base Select", () => {
features.base.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
describe("With Clause Select", () => {
features.withClause.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
describe("Select DISTINCT", () => {
features.distinct.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
})
})
describe("Select Window TVF", () => {
features.windowTVF.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
})
})
describe("Select Aggregation", () => {
features.aggregation.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
})
})
describe("Select Join", () => {
features.join.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
})
})
describe("Select Set Operations", () => {
features.setOperation.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
})
})
describe("Select Pattern Recognition", () => {
features.pattern.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
})
})
});