feat(flink): add describe/explain/use/show statement and some test

This commit is contained in:
Erindcl 2020-11-26 11:20:57 +08:00
parent d1259b46a0
commit 0ef80696f4
18 changed files with 12318 additions and 19115 deletions

View File

@ -0,0 +1,348 @@
lexer grammar FlinkSqlLexer;
// SKIP
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
LINE_COMMENT: (
('-- ' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
| '--' ('\r'? '\n' | EOF)
) -> channel(HIDDEN);
// Common Keywords
SELECT: 'SELECT';
FROM: 'FROM';
ADD: 'ADD';
AS: 'AS';
ALL: 'ALL';
ANY: 'ANY';
DISTINCT: 'DISTINCT';
WHERE: 'WHERE';
GROUP: 'GROUP';
BY: 'BY';
GROUPING: 'GROUPING';
SETS: 'SETS';
CUBE: 'CUBE';
ROLLUP: 'ROLLUP';
ORDER: 'ORDER';
HAVING: 'HAVING';
LIMIT: 'LIMIT';
AT: 'AT';
OR: 'OR';
AND: 'AND';
IN: 'IN';
NOT: 'NOT';
NO: 'NO';
EXISTS: 'EXISTS';
BETWEEN: 'BETWEEN';
LIKE: 'LIKE';
RLIKE: 'RLIKE';
IS: 'IS';
TRUE: 'TRUE';
FALSE: 'FALSE';
NULLS: 'NULLS';
ASC: 'ASC';
DESC: 'DESC';
FOR: 'FOR';
INTERVAL: 'INTERVAL';
CASE: 'CASE';
WHEN: 'WHEN';
THEN: 'THEN';
ELSE: 'ELSE';
END: 'END';
JOIN: 'JOIN';
CROSS: 'CROSS';
OUTER: 'OUTER';
INNER: 'INNER';
LEFT: 'LEFT';
SEMI: 'SEMI';
RIGHT: 'RIGHT';
FULL: 'FULL';
NATURAL: 'NATURAL';
ON: 'ON';
PIVOT: 'PIVOT';
LATERAL: 'LATERAL';
WINDOW: 'WINDOW';
OVER: 'OVER';
PARTITION: 'PARTITION';
RANGE: 'RANGE';
ROWS: 'ROWS';
UNBOUNDED: 'UNBOUNDED';
PRECEDING: 'PRECEDING';
FOLLOWING: 'FOLLOWING';
CURRENT: 'CURRENT';
FIRST: 'FIRST';
AFTER: 'AFTER';
LAST: 'LAST';
WITH: 'WITH';
VALUES: 'VALUES';
CREATE: 'CREATE';
TABLE: 'TABLE';
DIRECTORY: 'DIRECTORY';
VIEW: 'VIEW';
REPLACE: 'REPLACE';
INSERT: 'INSERT';
DELETE: 'DELETE';
INTO: 'INTO';
DESCRIBE: 'DESCRIBE';
EXPLAIN: 'EXPLAIN';
FORMAT: 'FORMAT';
LOGICAL: 'LOGICAL';
CODEGEN: 'CODEGEN';
COST: 'COST';
CAST: 'CAST';
SHOW: 'SHOW';
TABLES: 'TABLES';
COLUMNS: 'COLUMNS';
COLUMN: 'COLUMN';
USE: 'USE';
PARTITIONS: 'PARTITIONS';
FUNCTIONS: 'FUNCTIONS';
DROP: 'DROP';
UNION: 'UNION';
EXCEPT: 'EXCEPT';
SETMINUS: 'SETMINUS';
INTERSECT: 'INTERSECT';
TO: 'TO';
TABLESAMPLE: 'TABLESAMPLE';
STRATIFY: 'STRATIFY';
ALTER: 'ALTER';
RENAME: 'RENAME';
STRUCT: 'STRUCT';
COMMENT: 'COMMENT';
SET: 'SET';
RESET: 'RESET';
DATA: 'DATA';
START: 'START';
TRANSACTION: 'TRANSACTION';
COMMIT: 'COMMIT';
ROLLBACK: 'ROLLBACK';
MACRO: 'MACRO';
IGNORE: 'IGNORE';
BOTH: 'BOTH';
LEADING: 'LEADING';
TRAILING: 'TRAILING';
IF: 'IF';
POSITION: 'POSITION';
EXTRACT: 'EXTRACT';
EQ: 'EQ';
NSEQ: 'NSEQ';
NEQ: 'NEQ';
NEQJ: 'NEQJ';
LT: 'LT';
LTE: 'LTE';
GT: 'GT';
GTE: 'GTE';
PLUS: 'PLUS';
MINUS: 'MINUS';
ASTERISK: 'ASTERISK';
SLASH: 'SLASH';
PERCENT: 'PERCENT';
DIV: 'DIV';
TILDE: 'TILDE';
AMPERSAND: 'AMPERSAND';
PIPE: 'PIPE';
CONCAT_PIPE: 'CONCAT_PIPE';
HAT: 'HAT';
PERCENTLIT: 'PERCENTLIT';
BUCKET: 'BUCKET';
OUT: 'OUT';
OF: 'OF';
SORT: 'SORT';
CLUSTER: 'CLUSTER';
DISTRIBUTE: 'DISTRIBUTE';
OVERWRITE: 'OVERWRITE';
TRANSFORM: 'TRANSFORM';
REDUCE: 'REDUCE';
USING: 'USING';
SERDE: 'SERDE';
SERDEPROPERTIES: 'SERDEPROPERTIES';
RECORDREADER: 'RECORDREADER';
RECORDWRITER: 'RECORDWRITER';
DELIMITED: 'DELIMITED';
FIELDS: 'FIELDS';
TERMINATED: 'TERMINATED';
COLLECTION: 'COLLECTION';
ITEMS: 'ITEMS';
KEYS: 'KEYS';
ESCAPED: 'ESCAPED';
LINES: 'LINES';
SEPARATED: 'SEPARATED';
FUNCTION: 'FUNCTION';
EXTENDED: 'EXTENDED';
REFRESH: 'REFRESH';
CLEAR: 'CLEAR';
CACHE: 'CACHE';
UNCACHE: 'UNCACHE';
LAZY: 'LAZY';
FORMATTED: 'FORMATTED';
GLOBAL: 'GLOBAL';
TEMPORARY: 'TEMPORARY';
OPTIONS: 'OPTIONS';
UNSET: 'UNSET';
TBLPROPERTIES: 'TBLPROPERTIES';
DBPROPERTIES: 'DBPROPERTIES';
BUCKETS: 'BUCKETS';
SKEWED: 'SKEWED';
STORED: 'STORED';
DIRECTORIES: 'DIRECTORIES';
LOCATION: 'LOCATION';
EXCHANGE: 'EXCHANGE';
ARCHIVE: 'ARCHIVE';
UNARCHIVE: 'UNARCHIVE';
FILEFORMAT: 'FILEFORMAT';
TOUCH: 'TOUCH';
COMPACT: 'COMPACT';
CONCATENATE: 'CONCATENATE';
CHANGE: 'CHANGE';
CASCADE: 'CASCADE';
RESTRICT: 'RESTRICT';
CLUSTERED: 'CLUSTERED';
SORTED: 'SORTED';
PURGE: 'PURGE';
INPUTFORMAT: 'INPUTFORMAT';
OUTPUTFORMAT: 'OUTPUTFORMAT';
DATABASE: 'DATABASE';
DATABASES: 'DATABASES';
DFS: 'DFS';
TRUNCATE: 'TRUNCATE';
ANALYZE: 'ANALYZE';
COMPUTE: 'COMPUTE';
LIST: 'LIST';
STATISTICS: 'STATISTICS';
PARTITIONED: 'PARTITIONED';
EXTERNAL: 'EXTERNAL';
DEFINED: 'DEFINED';
REVOKE: 'REVOKE';
GRANT: 'GRANT';
LOCK: 'LOCK';
UNLOCK: 'UNLOCK';
MSCK: 'MSCK';
REPAIR: 'REPAIR';
RECOVER: 'RECOVER';
EXPORT: 'EXPORT';
IMPORT: 'IMPORT';
LOAD: 'LOAD';
ROLE: 'ROLE';
ROLES: 'ROLES';
COMPACTIONS: 'COMPACTIONS';
PRINCIPALS: 'PRINCIPALS';
TRANSACTIONS: 'TRANSACTIONS';
INDEX: 'INDEX';
INDEXES: 'INDEXES';
LOCKS: 'LOCKS';
OPTION: 'OPTION';
ANTI: 'ANTI';
LOCAL: 'LOCAL';
INPATH: 'INPATH';
WATERMARK: 'WATERMARK';
UNNEST: 'UNNEST';
MATCH_RECOGNIZE: 'MATCH_RECOGNIZE';
MEASURES: 'MEASURES';
ONE: 'ONE';
PER: 'PER';
MATCH: 'MATCH';
SKIP1: 'SKIP1';
NEXT: 'NEXT';
PAST: 'PAST';
PATTERN: 'PATTERN';
WITHIN: 'WITHIN';
DEFINE: 'DEFINE';
WS: 'WS';
SYSTEM: 'SYSTEM';
INCLUDING: 'INCLUDING';
EXCLUDING: 'EXCLUDING';
CONSTRAINTS: 'CONSTRAINTS';
OVERWRITING: 'OVERWRITING';
GENERATED: 'GENERATED';
CATALOG: 'CATALOG';
LANGUAGE: 'LANGUAGE';
CATALOGS: 'CATALOGS';
VIEWS: 'VIEWS';
// DATA TYPE Keywords
STRING: 'STRING';
ARRAY: 'ARRAY';
MAP: 'MAP';
CHAR: 'CHAR';
VARCHAR: 'VARCHAR';
BINARY: 'BINARY';
VARBINARY: 'VARBINARY';
BYTES: 'BYTES';
DECIMAL: 'DECIMAL';
TINYINT: 'TINYINT';
SMALLINT: 'SMALLINT';
INT: 'INT';
BIGINT: 'BIGINT';
FLOAT: 'FLOAT';
DOUBLE: 'DOUBLE';
DATE: 'DATE';
TIME: 'TIME';
TIMESTAMP: 'TIMESTAMP';
MULTISET: 'MULTISET';
BOOLEAN: 'BOOLEAN';
RAW: 'RAW';
ROW: 'ROW';
NULL: 'NULL';
// Operators. Comparation
EQUAL_SYMBOL: '=';
GREATER_SYMBOL: '>';
LESS_SYMBOL: '<';
EXCLAMATION_SYMBOL: '!';
// Operators. Bit
BIT_NOT_OP: '~';
BIT_OR_OP: '|';
BIT_AND_OP: '&';
BIT_XOR_OP: '^';
// Constructors symbols
DOT: '.';
LS_BRACKET: '[';
RS_BRACKET: ']';
LR_BRACKET: '(';
RR_BRACKET: ')';
COMMA: ',';
SEMICOLON: ';';
AT_SIGN: '@';
SINGLE_QUOTE_SYMB: '\'';
DOUBLE_QUOTE_SYMB: '"';
REVERSE_QUOTE_SYMB: '`';
COLON_SYMB: ':';
ASTERISK_SIGN: '*';
UNDERLINE_SIGN: '_';
HYPNEN_SIGN: '-';
ADD_SIGN: '+';
PENCENT_SIGN: '%';
DOUBLE_VERTICAL_SIGN: '||';
DOUBLE_HYPNEN_SIGN: '--';
SLASH_SIGN: '/';
DOT_ID: '.' ID_LITERAL;
STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING;
DIG_LITERAL: DEC_DIGIT+;
REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
| DEC_DIGIT+ '.' EXPONENT_NUM_PART
| (DEC_DIGIT+)? '.' (DEC_DIGIT+ EXPONENT_NUM_PART)
| DEC_DIGIT+ EXPONENT_NUM_PART;
BIT_STRING: BIT_STRING_L;
ID: ID_LITERAL;
fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+;
fragment ID_LITERAL: [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: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';
fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\'';
fragment BIT_STRING_L: 'B' '\'' [01]+ '\'';
fragment BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';

View File

@ -1,7 +1,6 @@
grammar FlinkSqlParser; parser grammar FlinkSqlParser;
// import FlinkSqlLexer; options { tokenVocab=FlinkSqlLexer; }
// options { tokenVocab=FlinkSqlLexer; }
program: statement EOF; program: statement EOF;
@ -10,11 +9,11 @@ statement
; ;
sqlStatements sqlStatements
: (sqlStatement SEMICOLON | emptyStatement)* : (sqlStatement SEMICOLON? | emptyStatement)*
; ;
sqlStatement sqlStatement
: ddlStatement | dmlStatement : ddlStatement | dmlStatement | describeStatement | explainStatement | useStatement | showStatememt
; ;
emptyStatement emptyStatement
@ -31,6 +30,22 @@ dmlStatement
: queryStatement | insertStatement : queryStatement | insertStatement
; ;
describeStatement
: DESCRIBE uid
;
explainStatement
: EXPLAIN identifier FOR dmlStatement
;
useStatement
: USE CATALOG? uid
;
showStatememt
: SHOW (CATALOGS | DATABASES | TABLES | FUNCTIONS | VIEWS)
;
// Create statements // Create statements
@ -111,7 +126,7 @@ createDatabase
; ;
createView createView
: CREATE TEMPORARY? VIEW ifNotExists? uid (columnName (',' columnName)*)? commentSpec AS queryStatement : CREATE TEMPORARY? VIEW ifNotExists? uid (columnName (',' columnName)*)? commentSpec? AS queryStatement
; ;
createFunction createFunction
@ -129,9 +144,7 @@ renameDefinition
; ;
setKeyValueDefinition setKeyValueDefinition
: SET LR_BRACKET : SET tablePropertyList
keyValueDefinition (COMMA keyValueDefinition)*
RR_BRACKET
; ;
alterDatabase alterDatabase
@ -139,7 +152,7 @@ alterDatabase
; ;
alterFunction alterFunction
: : ALTER (TEMPORARY|TEMPORARY SYSTEM) FUNCTION ifExists? uid AS identifier (LANGUAGE identifier)?
; ;
@ -167,15 +180,13 @@ dropFunction
insertStatement insertStatement
: INSERT (INTO | OVERWRITE) uid : INSERT (INTO | OVERWRITE) uid
( (
insertPartitionDefinition? selectStatement insertPartitionDefinition? queryStatement
| valuesDefinition | valuesDefinition
) )
; ;
insertPartitionDefinition insertPartitionDefinition
: PARTITION LR_BRACKET : PARTITION tablePropertyList
keyValueDefinition (COMMA keyValueDefinition)*
RR_BRACKET
; ;
valuesDefinition valuesDefinition
@ -334,7 +345,7 @@ valueExpression
: primaryExpression #valueExpressionDefault : primaryExpression #valueExpressionDefault
| operator=('-' | '+' | '~') valueExpression #arithmeticUnary | operator=('-' | '+' | '~') valueExpression #arithmeticUnary
| left=valueExpression operator=('*' | '/' | '%' | DIV) right=valueExpression #arithmeticBinary | left=valueExpression operator=('*' | '/' | '%' | DIV) right=valueExpression #arithmeticBinary
| left=valueExpression operator=('+' | '-' | '||') right=valueExpression #arithmeticBinary | left=valueExpression operator=('+' | '-' | DOUBLE_VERTICAL_SIGN) right=valueExpression #arithmeticBinary
| left=valueExpression operator='&' right=valueExpression #arithmeticBinary | left=valueExpression operator='&' right=valueExpression #arithmeticBinary
| left=valueExpression operator='^' right=valueExpression #arithmeticBinary | left=valueExpression operator='^' right=valueExpression #arithmeticBinary
| left=valueExpression operator='|' right=valueExpression #arithmeticBinary | left=valueExpression operator='|' right=valueExpression #arithmeticBinary
@ -470,10 +481,6 @@ ifNotExists
ifExists ifExists
: IF EXISTS; : IF EXISTS;
keyValueDefinition
: STRING_LITERAL EQUAL_SYMBOL STRING_LITERAL
;
tablePropertyList tablePropertyList
: '(' tableProperty (',' tableProperty)* ')' : '(' tableProperty (',' tableProperty)* ')'
; ;
@ -544,353 +551,3 @@ setQuantifier
: DISTINCT : DISTINCT
| ALL | ALL
; ;
/*
lexer grammar
*/
// SKIP
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
COMMENT_INPUT: '/*' .*? '*/' -> channel(HIDDEN);
LINE_COMMENT: (
('-- ' | '#') ~[\r\n]* ('\r'? '\n' | EOF)
| '--' ('\r'? '\n' | EOF)
) -> channel(HIDDEN);
// Common Keywords
SELECT: 'SELECT';
FROM: 'FROM';
ADD: 'ADD';
AS: 'AS';
ALL: 'ALL';
ANY: 'ANY';
DISTINCT: 'DISTINCT';
WHERE: 'WHERE';
GROUP: 'GROUP';
BY: 'BY';
GROUPING: 'GROUPING';
SETS: 'SETS';
CUBE: 'CUBE';
ROLLUP: 'ROLLUP';
ORDER: 'ORDER';
HAVING: 'HAVING';
LIMIT: 'LIMIT';
AT: 'AT';
OR: 'OR';
AND: 'AND';
IN: 'IN';
NOT: 'NOT';
NO: 'NO';
EXISTS: 'EXISTS';
BETWEEN: 'BETWEEN';
LIKE: 'LIKE';
RLIKE: 'RLIKE';
IS: 'IS';
TRUE: 'TRUE';
FALSE: 'FALSE';
NULLS: 'NULLS';
ASC: 'ASC';
DESC: 'DESC';
FOR: 'FOR';
INTERVAL: 'INTERVAL';
CASE: 'CASE';
WHEN: 'WHEN';
THEN: 'THEN';
ELSE: 'ELSE';
END: 'END';
JOIN: 'JOIN';
CROSS: 'CROSS';
OUTER: 'OUTER';
INNER: 'INNER';
LEFT: 'LEFT';
SEMI: 'SEMI';
RIGHT: 'RIGHT';
FULL: 'FULL';
NATURAL: 'NATURAL';
ON: 'ON';
PIVOT: 'PIVOT';
LATERAL: 'LATERAL';
WINDOW: 'WINDOW';
OVER: 'OVER';
PARTITION: 'PARTITION';
RANGE: 'RANGE';
ROWS: 'ROWS';
UNBOUNDED: 'UNBOUNDED';
PRECEDING: 'PRECEDING';
FOLLOWING: 'FOLLOWING';
CURRENT: 'CURRENT';
FIRST: 'FIRST';
AFTER: 'AFTER';
LAST: 'LAST';
WITH: 'WITH';
VALUES: 'VALUES';
CREATE: 'CREATE';
TABLE: 'TABLE';
DIRECTORY: 'DIRECTORY';
VIEW: 'VIEW';
REPLACE: 'REPLACE';
INSERT: 'INSERT';
DELETE: 'DELETE';
INTO: 'INTO';
DESCRIBE: 'DESCRIBE';
EXPLAIN: 'EXPLAIN';
FORMAT: 'FORMAT';
LOGICAL: 'LOGICAL';
CODEGEN: 'CODEGEN';
COST: 'COST';
CAST: 'CAST';
SHOW: 'SHOW';
TABLES: 'TABLES';
COLUMNS: 'COLUMNS';
COLUMN: 'COLUMN';
USE: 'USE';
PARTITIONS: 'PARTITIONS';
FUNCTIONS: 'FUNCTIONS';
DROP: 'DROP';
UNION: 'UNION';
EXCEPT: 'EXCEPT';
SETMINUS: 'SETMINUS';
INTERSECT: 'INTERSECT';
TO: 'TO';
TABLESAMPLE: 'TABLESAMPLE';
STRATIFY: 'STRATIFY';
ALTER: 'ALTER';
RENAME: 'RENAME';
STRUCT: 'STRUCT';
COMMENT: 'COMMENT';
SET: 'SET';
RESET: 'RESET';
DATA: 'DATA';
START: 'START';
TRANSACTION: 'TRANSACTION';
COMMIT: 'COMMIT';
ROLLBACK: 'ROLLBACK';
MACRO: 'MACRO';
IGNORE: 'IGNORE';
BOTH: 'BOTH';
LEADING: 'LEADING';
TRAILING: 'TRAILING';
IF: 'IF';
POSITION: 'POSITION';
EXTRACT: 'EXTRACT';
EQ: 'EQ';
NSEQ: 'NSEQ';
NEQ: 'NEQ';
NEQJ: 'NEQJ';
LT: 'LT';
LTE: 'LTE';
GT: 'GT';
GTE: 'GTE';
PLUS: 'PLUS';
MINUS: 'MINUS';
ASTERISK: 'ASTERISK';
SLASH: 'SLASH';
PERCENT: 'PERCENT';
DIV: 'DIV';
TILDE: 'TILDE';
AMPERSAND: 'AMPERSAND';
PIPE: 'PIPE';
CONCAT_PIPE: 'CONCAT_PIPE';
HAT: 'HAT';
PERCENTLIT: 'PERCENTLIT';
BUCKET: 'BUCKET';
OUT: 'OUT';
OF: 'OF';
SORT: 'SORT';
CLUSTER: 'CLUSTER';
DISTRIBUTE: 'DISTRIBUTE';
OVERWRITE: 'OVERWRITE';
TRANSFORM: 'TRANSFORM';
REDUCE: 'REDUCE';
USING: 'USING';
SERDE: 'SERDE';
SERDEPROPERTIES: 'SERDEPROPERTIES';
RECORDREADER: 'RECORDREADER';
RECORDWRITER: 'RECORDWRITER';
DELIMITED: 'DELIMITED';
FIELDS: 'FIELDS';
TERMINATED: 'TERMINATED';
COLLECTION: 'COLLECTION';
ITEMS: 'ITEMS';
KEYS: 'KEYS';
ESCAPED: 'ESCAPED';
LINES: 'LINES';
SEPARATED: 'SEPARATED';
FUNCTION: 'FUNCTION';
EXTENDED: 'EXTENDED';
REFRESH: 'REFRESH';
CLEAR: 'CLEAR';
CACHE: 'CACHE';
UNCACHE: 'UNCACHE';
LAZY: 'LAZY';
FORMATTED: 'FORMATTED';
GLOBAL: 'GLOBAL';
TEMPORARY: 'TEMPORARY';
OPTIONS: 'OPTIONS';
UNSET: 'UNSET';
TBLPROPERTIES: 'TBLPROPERTIES';
DBPROPERTIES: 'DBPROPERTIES';
BUCKETS: 'BUCKETS';
SKEWED: 'SKEWED';
STORED: 'STORED';
DIRECTORIES: 'DIRECTORIES';
LOCATION: 'LOCATION';
EXCHANGE: 'EXCHANGE';
ARCHIVE: 'ARCHIVE';
UNARCHIVE: 'UNARCHIVE';
FILEFORMAT: 'FILEFORMAT';
TOUCH: 'TOUCH';
COMPACT: 'COMPACT';
CONCATENATE: 'CONCATENATE';
CHANGE: 'CHANGE';
CASCADE: 'CASCADE';
RESTRICT: 'RESTRICT';
CLUSTERED: 'CLUSTERED';
SORTED: 'SORTED';
PURGE: 'PURGE';
INPUTFORMAT: 'INPUTFORMAT';
OUTPUTFORMAT: 'OUTPUTFORMAT';
DATABASE: 'DATABASE';
DATABASES: 'DATABASES';
DFS: 'DFS';
TRUNCATE: 'TRUNCATE';
ANALYZE: 'ANALYZE';
COMPUTE: 'COMPUTE';
LIST: 'LIST';
STATISTICS: 'STATISTICS';
PARTITIONED: 'PARTITIONED';
EXTERNAL: 'EXTERNAL';
DEFINED: 'DEFINED';
REVOKE: 'REVOKE';
GRANT: 'GRANT';
LOCK: 'LOCK';
UNLOCK: 'UNLOCK';
MSCK: 'MSCK';
REPAIR: 'REPAIR';
RECOVER: 'RECOVER';
EXPORT: 'EXPORT';
IMPORT: 'IMPORT';
LOAD: 'LOAD';
ROLE: 'ROLE';
ROLES: 'ROLES';
COMPACTIONS: 'COMPACTIONS';
PRINCIPALS: 'PRINCIPALS';
TRANSACTIONS: 'TRANSACTIONS';
INDEX: 'INDEX';
INDEXES: 'INDEXES';
LOCKS: 'LOCKS';
OPTION: 'OPTION';
ANTI: 'ANTI';
LOCAL: 'LOCAL';
INPATH: 'INPATH';
WATERMARK: 'WATERMARK';
UNNEST: 'UNNEST';
MATCH_RECOGNIZE: 'MATCH_RECOGNIZE';
MEASURES: 'MEASURES';
ONE: 'ONE';
PER: 'PER';
MATCH: 'MATCH';
SKIP1: 'SKIP1';
NEXT: 'NEXT';
PAST: 'PAST';
PATTERN: 'PATTERN';
WITHIN: 'WITHIN';
DEFINE: 'DEFINE';
WS: 'WS';
SYSTEM: 'SYSTEM';
INCLUDING: 'INCLUDING';
EXCLUDING: 'EXCLUDING';
CONSTRAINTS: 'CONSTRAINTS';
OVERWRITING: 'OVERWRITING';
GENERATED: 'GENERATED';
CATALOG: 'CATALOG';
LANGUAGE: 'LANGUAGE';
// DATA TYPE Keywords
STRING: 'STRING';
ARRAY: 'ARRAY';
MAP: 'MAP';
CHAR: 'CHAR';
VARCHAR: 'VARCHAR';
BINARY: 'BINARY';
VARBINARY: 'VARBINARY';
BYTES: 'BYTES';
DECIMAL: 'DECIMAL';
TINYINT: 'TINYINT';
SMALLINT: 'SMALLINT';
INT: 'INT';
BIGINT: 'BIGINT';
FLOAT: 'FLOAT';
DOUBLE: 'DOUBLE';
DATE: 'DATE';
TIME: 'TIME';
TIMESTAMP: 'TIMESTAMP';
MULTISET: 'MULTISET';
BOOLEAN: 'BOOLEAN';
RAW: 'RAW';
ROW: 'ROW';
NULL: 'NULL';
// Operators. Comparation
EQUAL_SYMBOL: '=';
GREATER_SYMBOL: '>';
LESS_SYMBOL: '<';
EXCLAMATION_SYMBOL: '!';
// Operators. Bit
BIT_NOT_OP: '~';
BIT_OR_OP: '|';
BIT_AND_OP: '&';
BIT_XOR_OP: '^';
// Constructors symbols
DOT: '.';
LS_BRACKET: '[';
RS_BRACKET: ']';
LR_BRACKET: '(';
RR_BRACKET: ')';
COMMA: ',';
SEMICOLON: ';';
AT_SIGN: '@';
SINGLE_QUOTE_SYMB: '\'';
DOUBLE_QUOTE_SYMB: '"';
REVERSE_QUOTE_SYMB: '`';
COLON_SYMB: ':';
ASTERISK_SIGN: '*';
UNDERLINE_SIGN: '_';
HYPNEN_SIGN: '-';
ADD_SIGN: '+';
PENCENT_SIGN: '%';
DOUBLE_HYPNEN_SIGN: '--';
SLASH_SIGN: '/';
DOT_ID: '.' ID_LITERAL;
STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING;
DIG_LITERAL: DEC_DIGIT+;
REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
| DEC_DIGIT+ '.' EXPONENT_NUM_PART
| (DEC_DIGIT+)? '.' (DEC_DIGIT+ EXPONENT_NUM_PART)
| DEC_DIGIT+ EXPONENT_NUM_PART;
BIT_STRING: BIT_STRING_L;
ID: ID_LITERAL;
fragment EXPONENT_NUM_PART: 'E' [-+]? DEC_DIGIT+;
fragment ID_LITERAL: [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: '"' ( '\\'. | '""' | ~('"'| '\\') )* '"';
fragment SQUOTA_STRING: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\'';
fragment BIT_STRING_L: 'B' '\'' [01]+ '\'';
fragment BQUOTA_STRING: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -239,82 +239,74 @@ PAST=238
PATTERN=239 PATTERN=239
WITHIN=240 WITHIN=240
DEFINE=241 DEFINE=241
BIGINT_LITERAL=242 WS=242
SMALLINT_LITERAL=243 SYSTEM=243
TINYINT_LITERAL=244 INCLUDING=244
INTEGER_VALUE=245 EXCLUDING=245
DECIMAL_VALUE=246 CONSTRAINTS=246
DOUBLE_LITERAL=247 OVERWRITING=247
BIGDECIMAL_LITERAL=248 GENERATED=248
IDENTIFIER=249 CATALOG=249
BACKQUOTED_IDENTIFIER=250 LANGUAGE=250
SIMPLE_COMMENT=251 CATALOGS=251
BRACKETED_EMPTY_COMMENT=252 VIEWS=252
BRACKETED_COMMENT=253 STRING=253
WS=254 ARRAY=254
UNRECOGNIZED=255 MAP=255
SYSTEM=256 CHAR=256
STRING=257 VARCHAR=257
ARRAY=258 BINARY=258
MAP=259 VARBINARY=259
CHAR=260 BYTES=260
VARCHAR=261 DECIMAL=261
BINARY=262 TINYINT=262
VARBINARY=263 SMALLINT=263
BYTES=264 INT=264
DECIMAL=265 BIGINT=265
TINYINT=266 FLOAT=266
SMALLINT=267 DOUBLE=267
INT=268 DATE=268
BIGINT=269 TIME=269
FLOAT=270 TIMESTAMP=270
DOUBLE=271 MULTISET=271
DATE=272 BOOLEAN=272
TIME=273 RAW=273
TIMESTAMP=274 ROW=274
MULTISET=275 NULL=275
BOOLEAN=276 EQUAL_SYMBOL=276
RAW=277 GREATER_SYMBOL=277
ROW=278 LESS_SYMBOL=278
NULL=279 EXCLAMATION_SYMBOL=279
EQUAL_SYMBOL=280 BIT_NOT_OP=280
GREATER_SYMBOL=281 BIT_OR_OP=281
LESS_SYMBOL=282 BIT_AND_OP=282
EXCLAMATION_SYMBOL=283 BIT_XOR_OP=283
BIT_NOT_OP=284 DOT=284
BIT_OR_OP=285 LS_BRACKET=285
BIT_AND_OP=286 RS_BRACKET=286
BIT_XOR_OP=287 LR_BRACKET=287
DOT=288 RR_BRACKET=288
LS_BRACKET=289 COMMA=289
RS_BRACKET=290 SEMICOLON=290
LR_BRACKET=291 AT_SIGN=291
RR_BRACKET=292 SINGLE_QUOTE_SYMB=292
COMMA=293 DOUBLE_QUOTE_SYMB=293
SEMICOLON=294 REVERSE_QUOTE_SYMB=294
AT_SIGN=295 COLON_SYMB=295
ZERO_DECIMAL=296 ASTERISK_SIGN=296
ONE_DECIMAL=297 UNDERLINE_SIGN=297
TWO_DECIMAL=298 HYPNEN_SIGN=298
SINGLE_QUOTE_SYMB=299 ADD_SIGN=299
DOUBLE_QUOTE_SYMB=300 PENCENT_SIGN=300
REVERSE_QUOTE_SYMB=301 DOUBLE_VERTICAL_SIGN=301
COLON_SYMB=302 DOUBLE_HYPNEN_SIGN=302
ASTERISK_SIGN=303 SLASH_SIGN=303
UNDERLINE_SIGN=304 DOT_ID=304
HYPNEN_SIGN=305 STRING_LITERAL=305
ADD_SIGN=306 DIG_LITERAL=306
PENCENT_SIGN=307 REAL_LITERAL=307
DOUBLE_HYPNEN_SIGN=308 BIT_STRING=308
SLASH_SIGN=309 ID=309
DOT_ID=310
ID=311
STRING_LITERAL=312
DECIMAL_LITERAL=313
REAL_LITERAL=314
BIT_STRING=315
IDENTIFIER_BASE=316
DEC_DIGIT=317
'SELECT'=4 'SELECT'=4
'FROM'=5 'FROM'=5
'ADD'=6 'ADD'=6
@ -553,71 +545,65 @@ DEC_DIGIT=317
'PATTERN'=239 'PATTERN'=239
'WITHIN'=240 'WITHIN'=240
'DEFINE'=241 'DEFINE'=241
'BIGINT_LITERAL'=242 'WS'=242
'SMALLINT_LITERAL'=243 'SYSTEM'=243
'TINYINT_LITERAL'=244 'INCLUDING'=244
'INTEGER_VALUE'=245 'EXCLUDING'=245
'DECIMAL_VALUE'=246 'CONSTRAINTS'=246
'DOUBLE_LITERAL'=247 'OVERWRITING'=247
'BIGDECIMAL_LITERAL'=248 'GENERATED'=248
'IDENTIFIER'=249 'CATALOG'=249
'BACKQUOTED_IDENTIFIER'=250 'LANGUAGE'=250
'SIMPLE_COMMENT'=251 'CATALOGS'=251
'BRACKETED_EMPTY_COMMENT'=252 'VIEWS'=252
'BRACKETED_COMMENT'=253 'STRING'=253
'WS'=254 'ARRAY'=254
'UNRECOGNIZED'=255 'MAP'=255
'SYSTEM'=256 'CHAR'=256
'STRING'=257 'VARCHAR'=257
'ARRAY'=258 'BINARY'=258
'MAP'=259 'VARBINARY'=259
'CHAR'=260 'BYTES'=260
'VARCHAR'=261 'DECIMAL'=261
'BINARY'=262 'TINYINT'=262
'VARBINARY'=263 'SMALLINT'=263
'BYTES'=264 'INT'=264
'DECIMAL'=265 'BIGINT'=265
'TINYINT'=266 'FLOAT'=266
'SMALLINT'=267 'DOUBLE'=267
'INT'=268 'DATE'=268
'BIGINT'=269 'TIME'=269
'FLOAT'=270 'TIMESTAMP'=270
'DOUBLE'=271 'MULTISET'=271
'DATE'=272 'BOOLEAN'=272
'TIME'=273 'RAW'=273
'TIMESTAMP'=274 'ROW'=274
'MULTISET'=275 'NULL'=275
'BOOLEAN'=276 '='=276
'RAW'=277 '>'=277
'ROW'=278 '<'=278
'NULL'=279 '!'=279
'='=280 '~'=280
'>'=281 '|'=281
'<'=282 '&'=282
'!'=283 '^'=283
'~'=284 '.'=284
'|'=285 '['=285
'&'=286 ']'=286
'^'=287 '('=287
'.'=288 ')'=288
'['=289 ','=289
']'=290 ';'=290
'('=291 '@'=291
')'=292 '\''=292
','=293 '"'=293
';'=294 '`'=294
'@'=295 ':'=295
'0'=296 '*'=296
'1'=297 '_'=297
'2'=298 '-'=298
'\''=299 '+'=299
'"'=300 '%'=300
'`'=301 '||'=301
':'=302 '--'=302
'*'=303 '/'=303
'_'=304
'-'=305
'+'=306
'%'=307
'--'=308
'/'=309

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,622 +0,0 @@
SPACE=1
COMMENT_INPUT=2
LINE_COMMENT=3
SELECT=4
FROM=5
ADD=6
AS=7
ALL=8
ANY=9
DISTINCT=10
WHERE=11
GROUP=12
BY=13
GROUPING=14
SETS=15
CUBE=16
ROLLUP=17
ORDER=18
HAVING=19
LIMIT=20
AT=21
OR=22
AND=23
IN=24
NOT=25
NO=26
EXISTS=27
BETWEEN=28
LIKE=29
RLIKE=30
IS=31
TRUE=32
FALSE=33
NULLS=34
ASC=35
DESC=36
FOR=37
INTERVAL=38
CASE=39
WHEN=40
THEN=41
ELSE=42
END=43
JOIN=44
CROSS=45
OUTER=46
INNER=47
LEFT=48
SEMI=49
RIGHT=50
FULL=51
NATURAL=52
ON=53
PIVOT=54
LATERAL=55
WINDOW=56
OVER=57
PARTITION=58
RANGE=59
ROWS=60
UNBOUNDED=61
PRECEDING=62
FOLLOWING=63
CURRENT=64
FIRST=65
AFTER=66
LAST=67
WITH=68
VALUES=69
CREATE=70
TABLE=71
DIRECTORY=72
VIEW=73
REPLACE=74
INSERT=75
DELETE=76
INTO=77
DESCRIBE=78
EXPLAIN=79
FORMAT=80
LOGICAL=81
CODEGEN=82
COST=83
CAST=84
SHOW=85
TABLES=86
COLUMNS=87
COLUMN=88
USE=89
PARTITIONS=90
FUNCTIONS=91
DROP=92
UNION=93
EXCEPT=94
SETMINUS=95
INTERSECT=96
TO=97
TABLESAMPLE=98
STRATIFY=99
ALTER=100
RENAME=101
STRUCT=102
COMMENT=103
SET=104
RESET=105
DATA=106
START=107
TRANSACTION=108
COMMIT=109
ROLLBACK=110
MACRO=111
IGNORE=112
BOTH=113
LEADING=114
TRAILING=115
IF=116
POSITION=117
EXTRACT=118
EQ=119
NSEQ=120
NEQ=121
NEQJ=122
LT=123
LTE=124
GT=125
GTE=126
PLUS=127
MINUS=128
ASTERISK=129
SLASH=130
PERCENT=131
DIV=132
TILDE=133
AMPERSAND=134
PIPE=135
CONCAT_PIPE=136
HAT=137
PERCENTLIT=138
BUCKET=139
OUT=140
OF=141
SORT=142
CLUSTER=143
DISTRIBUTE=144
OVERWRITE=145
TRANSFORM=146
REDUCE=147
USING=148
SERDE=149
SERDEPROPERTIES=150
RECORDREADER=151
RECORDWRITER=152
DELIMITED=153
FIELDS=154
TERMINATED=155
COLLECTION=156
ITEMS=157
KEYS=158
ESCAPED=159
LINES=160
SEPARATED=161
FUNCTION=162
EXTENDED=163
REFRESH=164
CLEAR=165
CACHE=166
UNCACHE=167
LAZY=168
FORMATTED=169
GLOBAL=170
TEMPORARY=171
OPTIONS=172
UNSET=173
TBLPROPERTIES=174
DBPROPERTIES=175
BUCKETS=176
SKEWED=177
STORED=178
DIRECTORIES=179
LOCATION=180
EXCHANGE=181
ARCHIVE=182
UNARCHIVE=183
FILEFORMAT=184
TOUCH=185
COMPACT=186
CONCATENATE=187
CHANGE=188
CASCADE=189
RESTRICT=190
CLUSTERED=191
SORTED=192
PURGE=193
INPUTFORMAT=194
OUTPUTFORMAT=195
DATABASE=196
DATABASES=197
DFS=198
TRUNCATE=199
ANALYZE=200
COMPUTE=201
LIST=202
STATISTICS=203
PARTITIONED=204
EXTERNAL=205
DEFINED=206
REVOKE=207
GRANT=208
LOCK=209
UNLOCK=210
MSCK=211
REPAIR=212
RECOVER=213
EXPORT=214
IMPORT=215
LOAD=216
ROLE=217
ROLES=218
COMPACTIONS=219
PRINCIPALS=220
TRANSACTIONS=221
INDEX=222
INDEXES=223
LOCKS=224
OPTION=225
ANTI=226
LOCAL=227
INPATH=228
WATERMARK=229
UNNEST=230
MATCH_RECOGNIZE=231
MEASURES=232
ONE=233
PER=234
MATCH=235
SKIP1=236
NEXT=237
PAST=238
PATTERN=239
WITHIN=240
DEFINE=241
BIGINT_LITERAL=242
SMALLINT_LITERAL=243
TINYINT_LITERAL=244
INTEGER_VALUE=245
DECIMAL_VALUE=246
DOUBLE_LITERAL=247
BIGDECIMAL_LITERAL=248
IDENTIFIER=249
BACKQUOTED_IDENTIFIER=250
SIMPLE_COMMENT=251
BRACKETED_EMPTY_COMMENT=252
BRACKETED_COMMENT=253
WS=254
UNRECOGNIZED=255
SYSTEM=256
STRING=257
ARRAY=258
MAP=259
CHAR=260
VARCHAR=261
BINARY=262
VARBINARY=263
BYTES=264
DECIMAL=265
TINYINT=266
SMALLINT=267
INT=268
BIGINT=269
FLOAT=270
DOUBLE=271
DATE=272
TIME=273
TIMESTAMP=274
MULTISET=275
BOOLEAN=276
RAW=277
ROW=278
NULL=279
EQUAL_SYMBOL=280
GREATER_SYMBOL=281
LESS_SYMBOL=282
EXCLAMATION_SYMBOL=283
BIT_NOT_OP=284
BIT_OR_OP=285
BIT_AND_OP=286
BIT_XOR_OP=287
DOT=288
LS_BRACKET=289
RS_BRACKET=290
LR_BRACKET=291
RR_BRACKET=292
COMMA=293
SEMICOLON=294
AT_SIGN=295
ZERO_DECIMAL=296
ONE_DECIMAL=297
TWO_DECIMAL=298
SINGLE_QUOTE_SYMB=299
DOUBLE_QUOTE_SYMB=300
REVERSE_QUOTE_SYMB=301
COLON_SYMB=302
ASTERISK_SIGN=303
UNDERLINE_SIGN=304
HYPNEN_SIGN=305
ADD_SIGN=306
PENCENT_SIGN=307
DOUBLE_HYPNEN_SIGN=308
SLASH_SIGN=309
DOT_ID=310
ID=311
STRING_LITERAL=312
DECIMAL_LITERAL=313
REAL_LITERAL=314
BIT_STRING=315
IDENTIFIER_BASE=316
'SELECT'=4
'FROM'=5
'ADD'=6
'AS'=7
'ALL'=8
'ANY'=9
'DISTINCT'=10
'WHERE'=11
'GROUP'=12
'BY'=13
'GROUPING'=14
'SETS'=15
'CUBE'=16
'ROLLUP'=17
'ORDER'=18
'HAVING'=19
'LIMIT'=20
'AT'=21
'OR'=22
'AND'=23
'IN'=24
'NOT'=25
'NO'=26
'EXISTS'=27
'BETWEEN'=28
'LIKE'=29
'RLIKE'=30
'IS'=31
'TRUE'=32
'FALSE'=33
'NULLS'=34
'ASC'=35
'DESC'=36
'FOR'=37
'INTERVAL'=38
'CASE'=39
'WHEN'=40
'THEN'=41
'ELSE'=42
'END'=43
'JOIN'=44
'CROSS'=45
'OUTER'=46
'INNER'=47
'LEFT'=48
'SEMI'=49
'RIGHT'=50
'FULL'=51
'NATURAL'=52
'ON'=53
'PIVOT'=54
'LATERAL'=55
'WINDOW'=56
'OVER'=57
'PARTITION'=58
'RANGE'=59
'ROWS'=60
'UNBOUNDED'=61
'PRECEDING'=62
'FOLLOWING'=63
'CURRENT'=64
'FIRST'=65
'AFTER'=66
'LAST'=67
'WITH'=68
'VALUES'=69
'CREATE'=70
'TABLE'=71
'DIRECTORY'=72
'VIEW'=73
'REPLACE'=74
'INSERT'=75
'DELETE'=76
'INTO'=77
'DESCRIBE'=78
'EXPLAIN'=79
'FORMAT'=80
'LOGICAL'=81
'CODEGEN'=82
'COST'=83
'CAST'=84
'SHOW'=85
'TABLES'=86
'COLUMNS'=87
'COLUMN'=88
'USE'=89
'PARTITIONS'=90
'FUNCTIONS'=91
'DROP'=92
'UNION'=93
'EXCEPT'=94
'SETMINUS'=95
'INTERSECT'=96
'TO'=97
'TABLESAMPLE'=98
'STRATIFY'=99
'ALTER'=100
'RENAME'=101
'STRUCT'=102
'COMMENT'=103
'SET'=104
'RESET'=105
'DATA'=106
'START'=107
'TRANSACTION'=108
'COMMIT'=109
'ROLLBACK'=110
'MACRO'=111
'IGNORE'=112
'BOTH'=113
'LEADING'=114
'TRAILING'=115
'IF'=116
'POSITION'=117
'EXTRACT'=118
'EQ'=119
'NSEQ'=120
'NEQ'=121
'NEQJ'=122
'LT'=123
'LTE'=124
'GT'=125
'GTE'=126
'PLUS'=127
'MINUS'=128
'ASTERISK'=129
'SLASH'=130
'PERCENT'=131
'DIV'=132
'TILDE'=133
'AMPERSAND'=134
'PIPE'=135
'CONCAT_PIPE'=136
'HAT'=137
'PERCENTLIT'=138
'BUCKET'=139
'OUT'=140
'OF'=141
'SORT'=142
'CLUSTER'=143
'DISTRIBUTE'=144
'OVERWRITE'=145
'TRANSFORM'=146
'REDUCE'=147
'USING'=148
'SERDE'=149
'SERDEPROPERTIES'=150
'RECORDREADER'=151
'RECORDWRITER'=152
'DELIMITED'=153
'FIELDS'=154
'TERMINATED'=155
'COLLECTION'=156
'ITEMS'=157
'KEYS'=158
'ESCAPED'=159
'LINES'=160
'SEPARATED'=161
'FUNCTION'=162
'EXTENDED'=163
'REFRESH'=164
'CLEAR'=165
'CACHE'=166
'UNCACHE'=167
'LAZY'=168
'FORMATTED'=169
'GLOBAL'=170
'TEMPORARY'=171
'OPTIONS'=172
'UNSET'=173
'TBLPROPERTIES'=174
'DBPROPERTIES'=175
'BUCKETS'=176
'SKEWED'=177
'STORED'=178
'DIRECTORIES'=179
'LOCATION'=180
'EXCHANGE'=181
'ARCHIVE'=182
'UNARCHIVE'=183
'FILEFORMAT'=184
'TOUCH'=185
'COMPACT'=186
'CONCATENATE'=187
'CHANGE'=188
'CASCADE'=189
'RESTRICT'=190
'CLUSTERED'=191
'SORTED'=192
'PURGE'=193
'INPUTFORMAT'=194
'OUTPUTFORMAT'=195
'DATABASE'=196
'DATABASES'=197
'DFS'=198
'TRUNCATE'=199
'ANALYZE'=200
'COMPUTE'=201
'LIST'=202
'STATISTICS'=203
'PARTITIONED'=204
'EXTERNAL'=205
'DEFINED'=206
'REVOKE'=207
'GRANT'=208
'LOCK'=209
'UNLOCK'=210
'MSCK'=211
'REPAIR'=212
'RECOVER'=213
'EXPORT'=214
'IMPORT'=215
'LOAD'=216
'ROLE'=217
'ROLES'=218
'COMPACTIONS'=219
'PRINCIPALS'=220
'TRANSACTIONS'=221
'INDEX'=222
'INDEXES'=223
'LOCKS'=224
'OPTION'=225
'ANTI'=226
'LOCAL'=227
'INPATH'=228
'WATERMARK'=229
'UNNEST'=230
'MATCH_RECOGNIZE'=231
'MEASURES'=232
'ONE'=233
'PER'=234
'MATCH'=235
'SKIP1'=236
'NEXT'=237
'PAST'=238
'PATTERN'=239
'WITHIN'=240
'DEFINE'=241
'BIGINT_LITERAL'=242
'SMALLINT_LITERAL'=243
'TINYINT_LITERAL'=244
'INTEGER_VALUE'=245
'DECIMAL_VALUE'=246
'DOUBLE_LITERAL'=247
'BIGDECIMAL_LITERAL'=248
'IDENTIFIER'=249
'BACKQUOTED_IDENTIFIER'=250
'SIMPLE_COMMENT'=251
'BRACKETED_EMPTY_COMMENT'=252
'BRACKETED_COMMENT'=253
'WS'=254
'UNRECOGNIZED'=255
'SYSTEM'=256
'STRING'=257
'ARRAY'=258
'MAP'=259
'CHAR'=260
'VARCHAR'=261
'BINARY'=262
'VARBINARY'=263
'BYTES'=264
'DECIMAL'=265
'TINYINT'=266
'SMALLINT'=267
'INT'=268
'BIGINT'=269
'FLOAT'=270
'DOUBLE'=271
'DATE'=272
'TIME'=273
'TIMESTAMP'=274
'MULTISET'=275
'BOOLEAN'=276
'RAW'=277
'ROW'=278
'NULL'=279
'='=280
'>'=281
'<'=282
'!'=283
'~'=284
'|'=285
'&'=286
'^'=287
'.'=288
'['=289
']'=290
'('=291
')'=292
','=293
';'=294
'@'=295
'0'=296
'1'=297
'2'=298
'\''=299
'"'=300
'`'=301
':'=302
'*'=303
'_'=304
'-'=305
'+'=306
'%'=307
'--'=308
'/'=309

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
// jshint ignore: start // jshint ignore: start
var antlr4 = require('antlr4/index'); var antlr4 = require('antlr4/index');
// This class defines a complete generic visitor for a parse tree produced by FlinkSqlParserParser. // This class defines a complete generic visitor for a parse tree produced by FlinkSqlParser.
function FlinkSqlParserVisitor() { function FlinkSqlParserVisitor() {
antlr4.tree.ParseTreeVisitor.call(this); antlr4.tree.ParseTreeVisitor.call(this);
@ -12,481 +12,775 @@ function FlinkSqlParserVisitor() {
FlinkSqlParserVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype); FlinkSqlParserVisitor.prototype = Object.create(antlr4.tree.ParseTreeVisitor.prototype);
FlinkSqlParserVisitor.prototype.constructor = FlinkSqlParserVisitor; FlinkSqlParserVisitor.prototype.constructor = FlinkSqlParserVisitor;
// Visit a parse tree produced by FlinkSqlParserParser#program. // Visit a parse tree produced by FlinkSqlParser#program.
FlinkSqlParserVisitor.prototype.visitProgram = function(ctx) { FlinkSqlParserVisitor.prototype.visitProgram = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#statement. // Visit a parse tree produced by FlinkSqlParser#statement.
FlinkSqlParserVisitor.prototype.visitStatement = function(ctx) { FlinkSqlParserVisitor.prototype.visitStatement = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#sqlStatements. // Visit a parse tree produced by FlinkSqlParser#sqlStatements.
FlinkSqlParserVisitor.prototype.visitSqlStatements = function(ctx) { FlinkSqlParserVisitor.prototype.visitSqlStatements = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#sqlStatement. // Visit a parse tree produced by FlinkSqlParser#sqlStatement.
FlinkSqlParserVisitor.prototype.visitSqlStatement = function(ctx) { FlinkSqlParserVisitor.prototype.visitSqlStatement = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#emptyStatement. // Visit a parse tree produced by FlinkSqlParser#emptyStatement.
FlinkSqlParserVisitor.prototype.visitEmptyStatement = function(ctx) { FlinkSqlParserVisitor.prototype.visitEmptyStatement = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#ddlStatement. // Visit a parse tree produced by FlinkSqlParser#ddlStatement.
FlinkSqlParserVisitor.prototype.visitDdlStatement = function(ctx) { FlinkSqlParserVisitor.prototype.visitDdlStatement = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#dmlStatement. // Visit a parse tree produced by FlinkSqlParser#dmlStatement.
FlinkSqlParserVisitor.prototype.visitDmlStatement = function(ctx) { FlinkSqlParserVisitor.prototype.visitDmlStatement = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#createTable. // Visit a parse tree produced by FlinkSqlParser#describeStatement.
FlinkSqlParserVisitor.prototype.visitDescribeStatement = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#explainStatement.
FlinkSqlParserVisitor.prototype.visitExplainStatement = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#useStatement.
FlinkSqlParserVisitor.prototype.visitUseStatement = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#showStatememt.
FlinkSqlParserVisitor.prototype.visitShowStatememt = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#createTable.
FlinkSqlParserVisitor.prototype.visitCreateTable = function(ctx) { FlinkSqlParserVisitor.prototype.visitCreateTable = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#columnOptionDefinition. // Visit a parse tree produced by FlinkSqlParser#columnOptionDefinition.
FlinkSqlParserVisitor.prototype.visitColumnOptionDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitColumnOptionDefinition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#columnName. // Visit a parse tree produced by FlinkSqlParser#columnName.
FlinkSqlParserVisitor.prototype.visitColumnName = function(ctx) { FlinkSqlParserVisitor.prototype.visitColumnName = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#columnType. // Visit a parse tree produced by FlinkSqlParser#columnType.
FlinkSqlParserVisitor.prototype.visitColumnType = function(ctx) { FlinkSqlParserVisitor.prototype.visitColumnType = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#partitionDefinition. // Visit a parse tree produced by FlinkSqlParser#lengthOneDimension.
FlinkSqlParserVisitor.prototype.visitLengthOneDimension = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#commentSpec.
FlinkSqlParserVisitor.prototype.visitCommentSpec = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#watermarkDefinition.
FlinkSqlParserVisitor.prototype.visitWatermarkDefinition = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#partitionDefinition.
FlinkSqlParserVisitor.prototype.visitPartitionDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitPartitionDefinition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#partitionColumnDefinition. // Visit a parse tree produced by FlinkSqlParser#transformList.
FlinkSqlParserVisitor.prototype.visitPartitionColumnDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitTransformList = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#partitionColumnName. // Visit a parse tree produced by FlinkSqlParser#identityTransform.
FlinkSqlParserVisitor.prototype.visitPartitionColumnName = function(ctx) { FlinkSqlParserVisitor.prototype.visitIdentityTransform = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#createDatabase. // Visit a parse tree produced by FlinkSqlParser#applyTransform.
FlinkSqlParserVisitor.prototype.visitApplyTransform = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#transformArgument.
FlinkSqlParserVisitor.prototype.visitTransformArgument = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#likeDefinition.
FlinkSqlParserVisitor.prototype.visitLikeDefinition = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#likeOption.
FlinkSqlParserVisitor.prototype.visitLikeOption = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#createCatalog.
FlinkSqlParserVisitor.prototype.visitCreateCatalog = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#createDatabase.
FlinkSqlParserVisitor.prototype.visitCreateDatabase = function(ctx) { FlinkSqlParserVisitor.prototype.visitCreateDatabase = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#createView. // Visit a parse tree produced by FlinkSqlParser#createView.
FlinkSqlParserVisitor.prototype.visitCreateView = function(ctx) { FlinkSqlParserVisitor.prototype.visitCreateView = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#createFunction. // Visit a parse tree produced by FlinkSqlParser#createFunction.
FlinkSqlParserVisitor.prototype.visitCreateFunction = function(ctx) { FlinkSqlParserVisitor.prototype.visitCreateFunction = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#alterTable. // Visit a parse tree produced by FlinkSqlParser#alterTable.
FlinkSqlParserVisitor.prototype.visitAlterTable = function(ctx) { FlinkSqlParserVisitor.prototype.visitAlterTable = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#renameDefinition. // Visit a parse tree produced by FlinkSqlParser#renameDefinition.
FlinkSqlParserVisitor.prototype.visitRenameDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitRenameDefinition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#setKeyValueDefinition. // Visit a parse tree produced by FlinkSqlParser#setKeyValueDefinition.
FlinkSqlParserVisitor.prototype.visitSetKeyValueDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitSetKeyValueDefinition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#alterDatabase. // Visit a parse tree produced by FlinkSqlParser#alterDatabase.
FlinkSqlParserVisitor.prototype.visitAlterDatabase = function(ctx) { FlinkSqlParserVisitor.prototype.visitAlterDatabase = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#alterFunction. // Visit a parse tree produced by FlinkSqlParser#alterFunction.
FlinkSqlParserVisitor.prototype.visitAlterFunction = function(ctx) { FlinkSqlParserVisitor.prototype.visitAlterFunction = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#dropTable. // Visit a parse tree produced by FlinkSqlParser#dropTable.
FlinkSqlParserVisitor.prototype.visitDropTable = function(ctx) { FlinkSqlParserVisitor.prototype.visitDropTable = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#dropDatabase. // Visit a parse tree produced by FlinkSqlParser#dropDatabase.
FlinkSqlParserVisitor.prototype.visitDropDatabase = function(ctx) { FlinkSqlParserVisitor.prototype.visitDropDatabase = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#dropView. // Visit a parse tree produced by FlinkSqlParser#dropView.
FlinkSqlParserVisitor.prototype.visitDropView = function(ctx) { FlinkSqlParserVisitor.prototype.visitDropView = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#dropFunction. // Visit a parse tree produced by FlinkSqlParser#dropFunction.
FlinkSqlParserVisitor.prototype.visitDropFunction = function(ctx) { FlinkSqlParserVisitor.prototype.visitDropFunction = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#insertStatement. // Visit a parse tree produced by FlinkSqlParser#insertStatement.
FlinkSqlParserVisitor.prototype.visitInsertStatement = function(ctx) { FlinkSqlParserVisitor.prototype.visitInsertStatement = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#insertPartitionDefinition. // Visit a parse tree produced by FlinkSqlParser#insertPartitionDefinition.
FlinkSqlParserVisitor.prototype.visitInsertPartitionDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitInsertPartitionDefinition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#valuesDefinition. // Visit a parse tree produced by FlinkSqlParser#valuesDefinition.
FlinkSqlParserVisitor.prototype.visitValuesDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitValuesDefinition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#valuesRowDefinition. // Visit a parse tree produced by FlinkSqlParser#valuesRowDefinition.
FlinkSqlParserVisitor.prototype.visitValuesRowDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitValuesRowDefinition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#allValueDifinition. // Visit a parse tree produced by FlinkSqlParser#queryStatement.
FlinkSqlParserVisitor.prototype.visitAllValueDifinition = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParserParser#queryStatement.
FlinkSqlParserVisitor.prototype.visitQueryStatement = function(ctx) { FlinkSqlParserVisitor.prototype.visitQueryStatement = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#selectStatement. // Visit a parse tree produced by FlinkSqlParser#valuesCaluse.
FlinkSqlParserVisitor.prototype.visitValuesCaluse = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#selectStatement.
FlinkSqlParserVisitor.prototype.visitSelectStatement = function(ctx) { FlinkSqlParserVisitor.prototype.visitSelectStatement = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#projectItemDefinition. // Visit a parse tree produced by FlinkSqlParser#selectClause.
FlinkSqlParserVisitor.prototype.visitSelectClause = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#projectItemDefinition.
FlinkSqlParserVisitor.prototype.visitProjectItemDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitProjectItemDefinition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#tableExpression. // Visit a parse tree produced by FlinkSqlParser#fromClause.
FlinkSqlParserVisitor.prototype.visitFromClause = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#tableExpression.
FlinkSqlParserVisitor.prototype.visitTableExpression = function(ctx) { FlinkSqlParserVisitor.prototype.visitTableExpression = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#tableReference. // Visit a parse tree produced by FlinkSqlParser#tableReference.
FlinkSqlParserVisitor.prototype.visitTableReference = function(ctx) { FlinkSqlParserVisitor.prototype.visitTableReference = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#tablePrimary. // Visit a parse tree produced by FlinkSqlParser#tablePrimary.
FlinkSqlParserVisitor.prototype.visitTablePrimary = function(ctx) { FlinkSqlParserVisitor.prototype.visitTablePrimary = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#expression. // Visit a parse tree produced by FlinkSqlParser#joinCondition.
FlinkSqlParserVisitor.prototype.visitJoinCondition = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#whereClause.
FlinkSqlParserVisitor.prototype.visitWhereClause = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#groupByClause.
FlinkSqlParserVisitor.prototype.visitGroupByClause = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#groupItemDefinition.
FlinkSqlParserVisitor.prototype.visitGroupItemDefinition = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#havingClause.
FlinkSqlParserVisitor.prototype.visitHavingClause = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#orderByCaluse.
FlinkSqlParserVisitor.prototype.visitOrderByCaluse = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#orderItemDefition.
FlinkSqlParserVisitor.prototype.visitOrderItemDefition = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#limitClause.
FlinkSqlParserVisitor.prototype.visitLimitClause = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#windowClause.
FlinkSqlParserVisitor.prototype.visitWindowClause = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#namedWindow.
FlinkSqlParserVisitor.prototype.visitNamedWindow = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#windowSpec.
FlinkSqlParserVisitor.prototype.visitWindowSpec = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#sortItem.
FlinkSqlParserVisitor.prototype.visitSortItem = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#windowFrame.
FlinkSqlParserVisitor.prototype.visitWindowFrame = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#frameBound.
FlinkSqlParserVisitor.prototype.visitFrameBound = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#expression.
FlinkSqlParserVisitor.prototype.visitExpression = function(ctx) { FlinkSqlParserVisitor.prototype.visitExpression = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#logicalNot. // Visit a parse tree produced by FlinkSqlParser#logicalNot.
FlinkSqlParserVisitor.prototype.visitLogicalNot = function(ctx) { FlinkSqlParserVisitor.prototype.visitLogicalNot = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#predicated. // Visit a parse tree produced by FlinkSqlParser#predicated.
FlinkSqlParserVisitor.prototype.visitPredicated = function(ctx) { FlinkSqlParserVisitor.prototype.visitPredicated = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#logicalBinary. // Visit a parse tree produced by FlinkSqlParser#exists.
FlinkSqlParserVisitor.prototype.visitExists = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#logicalBinary.
FlinkSqlParserVisitor.prototype.visitLogicalBinary = function(ctx) { FlinkSqlParserVisitor.prototype.visitLogicalBinary = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#predicate. // Visit a parse tree produced by FlinkSqlParser#predicate.
FlinkSqlParserVisitor.prototype.visitPredicate = function(ctx) { FlinkSqlParserVisitor.prototype.visitPredicate = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#valueExpressionDefault. // Visit a parse tree produced by FlinkSqlParser#valueExpressionDefault.
FlinkSqlParserVisitor.prototype.visitValueExpressionDefault = function(ctx) { FlinkSqlParserVisitor.prototype.visitValueExpressionDefault = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#comparison. // Visit a parse tree produced by FlinkSqlParser#comparison.
FlinkSqlParserVisitor.prototype.visitComparison = function(ctx) { FlinkSqlParserVisitor.prototype.visitComparison = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#arithmeticBinary. // Visit a parse tree produced by FlinkSqlParser#arithmeticBinary.
FlinkSqlParserVisitor.prototype.visitArithmeticBinary = function(ctx) { FlinkSqlParserVisitor.prototype.visitArithmeticBinary = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#arithmeticUnary. // Visit a parse tree produced by FlinkSqlParser#arithmeticUnary.
FlinkSqlParserVisitor.prototype.visitArithmeticUnary = function(ctx) { FlinkSqlParserVisitor.prototype.visitArithmeticUnary = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#simpleCase. // Visit a parse tree produced by FlinkSqlParser#dereference.
FlinkSqlParserVisitor.prototype.visitDereference = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#simpleCase.
FlinkSqlParserVisitor.prototype.visitSimpleCase = function(ctx) { FlinkSqlParserVisitor.prototype.visitSimpleCase = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#constantDefault. // Visit a parse tree produced by FlinkSqlParser#columnReference.
FlinkSqlParserVisitor.prototype.visitConstantDefault = function(ctx) { FlinkSqlParserVisitor.prototype.visitColumnReference = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#parenthesizedExpression. // Visit a parse tree produced by FlinkSqlParser#last.
FlinkSqlParserVisitor.prototype.visitParenthesizedExpression = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParserParser#last.
FlinkSqlParserVisitor.prototype.visitLast = function(ctx) { FlinkSqlParserVisitor.prototype.visitLast = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#star. // Visit a parse tree produced by FlinkSqlParser#star.
FlinkSqlParserVisitor.prototype.visitStar = function(ctx) { FlinkSqlParserVisitor.prototype.visitStar = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#subscript. // Visit a parse tree produced by FlinkSqlParser#subscript.
FlinkSqlParserVisitor.prototype.visitSubscript = function(ctx) { FlinkSqlParserVisitor.prototype.visitSubscript = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#searchedCase. // Visit a parse tree produced by FlinkSqlParser#subqueryExpression.
FlinkSqlParserVisitor.prototype.visitSubqueryExpression = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#constantDefault.
FlinkSqlParserVisitor.prototype.visitConstantDefault = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#parenthesizedExpression.
FlinkSqlParserVisitor.prototype.visitParenthesizedExpression = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#functionCall.
FlinkSqlParserVisitor.prototype.visitFunctionCall = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#searchedCase.
FlinkSqlParserVisitor.prototype.visitSearchedCase = function(ctx) { FlinkSqlParserVisitor.prototype.visitSearchedCase = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#position. // Visit a parse tree produced by FlinkSqlParser#position.
FlinkSqlParserVisitor.prototype.visitPosition = function(ctx) { FlinkSqlParserVisitor.prototype.visitPosition = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#first. // Visit a parse tree produced by FlinkSqlParser#first.
FlinkSqlParserVisitor.prototype.visitFirst = function(ctx) { FlinkSqlParserVisitor.prototype.visitFirst = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#tableAlias. // Visit a parse tree produced by FlinkSqlParser#functionName.
FlinkSqlParserVisitor.prototype.visitFunctionName = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#dereferenceDefinition.
FlinkSqlParserVisitor.prototype.visitDereferenceDefinition = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#qualifiedName.
FlinkSqlParserVisitor.prototype.visitQualifiedName = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#interval.
FlinkSqlParserVisitor.prototype.visitInterval = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#errorCapturingMultiUnitsInterval.
FlinkSqlParserVisitor.prototype.visitErrorCapturingMultiUnitsInterval = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#multiUnitsInterval.
FlinkSqlParserVisitor.prototype.visitMultiUnitsInterval = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#errorCapturingUnitToUnitInterval.
FlinkSqlParserVisitor.prototype.visitErrorCapturingUnitToUnitInterval = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#unitToUnitInterval.
FlinkSqlParserVisitor.prototype.visitUnitToUnitInterval = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#intervalValue.
FlinkSqlParserVisitor.prototype.visitIntervalValue = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#tableAlias.
FlinkSqlParserVisitor.prototype.visitTableAlias = function(ctx) { FlinkSqlParserVisitor.prototype.visitTableAlias = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#identifierList. // Visit a parse tree produced by FlinkSqlParser#errorCapturingIdentifier.
FlinkSqlParserVisitor.prototype.visitErrorCapturingIdentifier = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#errorIdent.
FlinkSqlParserVisitor.prototype.visitErrorIdent = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#realIdent.
FlinkSqlParserVisitor.prototype.visitRealIdent = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#identifierList.
FlinkSqlParserVisitor.prototype.visitIdentifierList = function(ctx) { FlinkSqlParserVisitor.prototype.visitIdentifierList = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#identifierSeq. // Visit a parse tree produced by FlinkSqlParser#identifierSeq.
FlinkSqlParserVisitor.prototype.visitIdentifierSeq = function(ctx) { FlinkSqlParserVisitor.prototype.visitIdentifierSeq = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#identifier. // Visit a parse tree produced by FlinkSqlParser#identifier.
FlinkSqlParserVisitor.prototype.visitIdentifier = function(ctx) { FlinkSqlParserVisitor.prototype.visitIdentifier = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#unquotedIdentifier. // Visit a parse tree produced by FlinkSqlParser#unquotedIdentifierAlternative.
FlinkSqlParserVisitor.prototype.visitUnquotedIdentifier = function(ctx) { FlinkSqlParserVisitor.prototype.visitUnquotedIdentifierAlternative = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#quotedIdentifierAlternative. // Visit a parse tree produced by FlinkSqlParser#quotedIdentifierAlternative.
FlinkSqlParserVisitor.prototype.visitQuotedIdentifierAlternative = function(ctx) { FlinkSqlParserVisitor.prototype.visitQuotedIdentifierAlternative = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#quotedIdentifier. // Visit a parse tree produced by FlinkSqlParser#unquotedIdentifier.
FlinkSqlParserVisitor.prototype.visitUnquotedIdentifier = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#quotedIdentifier.
FlinkSqlParserVisitor.prototype.visitQuotedIdentifier = function(ctx) { FlinkSqlParserVisitor.prototype.visitQuotedIdentifier = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#whenClause. // Visit a parse tree produced by FlinkSqlParser#whenClause.
FlinkSqlParserVisitor.prototype.visitWhenClause = function(ctx) { FlinkSqlParserVisitor.prototype.visitWhenClause = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#uidList. // Visit a parse tree produced by FlinkSqlParser#uidList.
FlinkSqlParserVisitor.prototype.visitUidList = function(ctx) { FlinkSqlParserVisitor.prototype.visitUidList = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#uid. // Visit a parse tree produced by FlinkSqlParser#uid.
FlinkSqlParserVisitor.prototype.visitUid = function(ctx) { FlinkSqlParserVisitor.prototype.visitUid = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#withOption. // Visit a parse tree produced by FlinkSqlParser#withOption.
FlinkSqlParserVisitor.prototype.visitWithOption = function(ctx) { FlinkSqlParserVisitor.prototype.visitWithOption = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#ifNotExists. // Visit a parse tree produced by FlinkSqlParser#ifNotExists.
FlinkSqlParserVisitor.prototype.visitIfNotExists = function(ctx) { FlinkSqlParserVisitor.prototype.visitIfNotExists = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#ifExists. // Visit a parse tree produced by FlinkSqlParser#ifExists.
FlinkSqlParserVisitor.prototype.visitIfExists = function(ctx) { FlinkSqlParserVisitor.prototype.visitIfExists = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#keyValueDefinition. // Visit a parse tree produced by FlinkSqlParser#tablePropertyList.
FlinkSqlParserVisitor.prototype.visitKeyValueDefinition = function(ctx) { FlinkSqlParserVisitor.prototype.visitTablePropertyList = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#logicalOperator. // Visit a parse tree produced by FlinkSqlParser#tableProperty.
FlinkSqlParserVisitor.prototype.visitTableProperty = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#tablePropertyKey.
FlinkSqlParserVisitor.prototype.visitTablePropertyKey = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#tablePropertyValue.
FlinkSqlParserVisitor.prototype.visitTablePropertyValue = function(ctx) {
return this.visitChildren(ctx);
};
// Visit a parse tree produced by FlinkSqlParser#logicalOperator.
FlinkSqlParserVisitor.prototype.visitLogicalOperator = function(ctx) { FlinkSqlParserVisitor.prototype.visitLogicalOperator = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#comparisonOperator. // Visit a parse tree produced by FlinkSqlParser#comparisonOperator.
FlinkSqlParserVisitor.prototype.visitComparisonOperator = function(ctx) { FlinkSqlParserVisitor.prototype.visitComparisonOperator = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#bitOperator. // Visit a parse tree produced by FlinkSqlParser#bitOperator.
FlinkSqlParserVisitor.prototype.visitBitOperator = function(ctx) { FlinkSqlParserVisitor.prototype.visitBitOperator = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#mathOperator. // Visit a parse tree produced by FlinkSqlParser#mathOperator.
FlinkSqlParserVisitor.prototype.visitMathOperator = function(ctx) { FlinkSqlParserVisitor.prototype.visitMathOperator = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#unaryOperator. // Visit a parse tree produced by FlinkSqlParser#unaryOperator.
FlinkSqlParserVisitor.prototype.visitUnaryOperator = function(ctx) { FlinkSqlParserVisitor.prototype.visitUnaryOperator = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#fullColumnName. // Visit a parse tree produced by FlinkSqlParser#fullColumnName.
FlinkSqlParserVisitor.prototype.visitFullColumnName = function(ctx) { FlinkSqlParserVisitor.prototype.visitFullColumnName = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#constant. // Visit a parse tree produced by FlinkSqlParser#constant.
FlinkSqlParserVisitor.prototype.visitConstant = function(ctx) { FlinkSqlParserVisitor.prototype.visitConstant = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#stringLiteral. // Visit a parse tree produced by FlinkSqlParser#stringLiteral.
FlinkSqlParserVisitor.prototype.visitStringLiteral = function(ctx) { FlinkSqlParserVisitor.prototype.visitStringLiteral = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#decimalLiteral. // Visit a parse tree produced by FlinkSqlParser#decimalLiteral.
FlinkSqlParserVisitor.prototype.visitDecimalLiteral = function(ctx) { FlinkSqlParserVisitor.prototype.visitDecimalLiteral = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#booleanLiteral. // Visit a parse tree produced by FlinkSqlParser#booleanLiteral.
FlinkSqlParserVisitor.prototype.visitBooleanLiteral = function(ctx) { FlinkSqlParserVisitor.prototype.visitBooleanLiteral = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };
// Visit a parse tree produced by FlinkSqlParserParser#setQuantifier. // Visit a parse tree produced by FlinkSqlParser#setQuantifier.
FlinkSqlParserVisitor.prototype.visitSetQuantifier = function(ctx) { FlinkSqlParserVisitor.prototype.visitSetQuantifier = function(ctx) {
return this.visitChildren(ctx); return this.visitChildren(ctx);
}; };

View File

@ -8,7 +8,7 @@ import BasicParser from './common/BasicParser';
export default class FlinkSQL extends BasicParser { export default class FlinkSQL extends BasicParser {
public createLexer(input: string): Lexer { public createLexer(input: string): Lexer {
const chars = new InputStream(input); const chars = new InputStream(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform
const lexer = <unknown> new FlinkSqlLexer(chars) as Lexer; const lexer = <unknown> new FlinkSqlLexer(chars) as Lexer;
return lexer; return lexer;
} }

View File

@ -1,5 +1,4 @@
import SQLParser from '../../../src/parser/flinksql'; import SQLParser from '../../../src/parser/flinksql';
// todo 校验 token 解析
describe('FlinkSQL Lexer tests', () => { describe('FlinkSQL Lexer tests', () => {
const parser = new SQLParser(); const parser = new SQLParser();
@ -7,6 +6,6 @@ describe('FlinkSQL Lexer tests', () => {
const tokens = parser.getAllTokens(sql); const tokens = parser.getAllTokens(sql);
test('token counts', () => { test('token counts', () => {
expect(tokens.length).toBe(6); expect(tokens.length).toBe(7);
}); });
}); });

View File

@ -15,8 +15,7 @@ describe('FlinkSQL Syntax Tests', () => {
`; `;
const result = parser.validate(sql); const result = parser.validate(sql);
console.log(result); console.log(result);
// TODO find parser error expect(result.length).toBe(0);
expect(result.length).toBe(1);
}); });
test('Test simple CreateDatabase Statement', () => { test('Test simple CreateDatabase Statement', () => {
const sql = ` const sql = `
@ -28,14 +27,21 @@ describe('FlinkSQL Syntax Tests', () => {
const result = parser.validate(sql); const result = parser.validate(sql);
expect(result.length).toBe(0); expect(result.length).toBe(0);
}); });
// test('Test simple CreateView Statement', () => { test('Test simple CreateView Statement', () => {
// const sql = ` const sql = `
// CREATE TEMPORARY VIEW IF NOT EXISTS tempView CREATE TEMPORARY VIEW IF NOT EXISTS tempView
// AS ; AS SELECT product, amount FROM Orders;
// `; `;
// const result = parser.validate(sql); const result = parser.validate(sql);
// expect(result.length).toBe(0); expect(result.length).toBe(0);
// }); });
test('Test simple CreateFunction Statement', () => {
const sql = `
CREATE TEMPORARY FUNCTION IF NOT EXISTS tempFunction AS 'SimpleUdf';
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
// Alter statements // Alter statements
test('Test simple AlterTable Statement', () => { test('Test simple AlterTable Statement', () => {
@ -44,7 +50,14 @@ describe('FlinkSQL Syntax Tests', () => {
expect(result.length).toBe(0); expect(result.length).toBe(0);
}); });
test('Test simple AlterDatabase Statement', () => { test('Test simple AlterDatabase Statement', () => {
const sql = `ALTER DATABASE DataBase SET ("key1"="value1");`; const sql = `ALTER DATABASE tempDB SET ("key1"="value1");`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test simple AlterFunction Statement', () => {
const sql = `
ALTER TEMPORARY FUNCTION IF EXISTS tempFunction AS 'SimpleUdf';
`;
const result = parser.validate(sql); const result = parser.validate(sql);
expect(result.length).toBe(0); expect(result.length).toBe(0);
}); });
@ -70,10 +83,93 @@ describe('FlinkSQL Syntax Tests', () => {
const result = parser.validate(sql); const result = parser.validate(sql);
expect(result.length).toBe(0); expect(result.length).toBe(0);
}); });
// insert statements
test('Test one simple Insert Statement', () => {
const sql = `
INSERT INTO students VALUES
('Amy Smith', '123 Park Ave, San Jose', 111111);
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test two simple Insert Statement', () => {
const sql = `
INSERT INTO students PARTITION (student_id = 444444)
SELECT name, address FROM persons WHERE name = "Dora Williams";
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
// query statements
test('Test simple Select Statement', () => { test('Test simple Select Statement', () => {
const sql = `SELECT product, amount FROM Orders;`; const sql = `SELECT product, amount FROM Orders;`;
const result = parser.validate(sql); const result = parser.validate(sql);
console.log(result); expect(result.length).toBe(0);
});
test('Test Select Statement with where clause', () => {
const sql = `SELECT * FROM person WHERE id = 200 OR id = 300;`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test Select Statement with group by clause', () => {
const sql = `SELECT id, sum(quantity) FROM dealer GROUP BY id;`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test Select Statement with having clause', () => {
const sql = `
SELECT city, sum(quantity) AS sum
FROM dealer GROUP BY city HAVING city = 'Fremont';
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test Select Statement with order by clause', () => {
const sql = `SELECT name, age FROM person ORDER BY age;`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test Select Statement with limit clause', () => {
const sql = `SELECT name, age FROM person ORDER BY name LIMIT 2;`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
test('Test Select Statement with join', () => {
const sql = `
SELECT id, name, employee.deptno, deptname FROM employee
FULL JOIN department ON employee.deptno = department.deptno;
`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
// describe statements
test('Test simple Describe Statement', () => {
const sql = `DESCRIBE Orders;`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
// describe statements
test('Test simple Explain Statement', () => {
const sql = `EXPLAIN tempTable FOR SELECT k, SUM(v) FROM oneTable;`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
// use statements
test('Test simple Use Statement', () => {
const sql = `USE CATALOG orders;`;
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
// show statements
test('Test simple Show Statement', () => {
const sql = `SHOW CATALOGS;`;
const result = parser.validate(sql);
expect(result.length).toBe(0); expect(result.length).toBe(0);
}); });
}); });

View File

@ -1,23 +0,0 @@
import SQLParser, { PlSqlParserVisitor } from '../../../src/parser/plsql';
// todo 校验关键字提取
describe('PLSQL Visitor Tests', () => {
const expectTableName = 'user1';
const sql = `select id,name,sex from ${expectTableName};`;
const parser = new SQLParser();
const parserTree = parser.parse(sql);
test('Visitor visitTable_ref_list', () => {
let result = '';
class MyVisitor extends PlSqlParserVisitor {
visitTable_ref_list(ctx): void {
result = ctx.getText().toLowerCase();
super.visitTable_ref_list(ctx);
}
}
const visitor: any = new MyVisitor();
visitor.visit(parserTree);
expect(result).toBe(expectTableName);
});
});