refactor: improve keywords definations (#100)

* feat: improve keywords definations and add prefix named KW_

* test: capitalize keywords in alter sql test cases

* test: capitalize keywords in create sql test cases

* feat: merge interval rule and timeIntervalExpression rule in flinksql grammar

* test: put keywords in quotation marks around insert sql test cases

* test: put keywords in quotation marks around select sql test cases

* feat: improve uid rule

* test: rename sum to _sum because it is a reserved keyword

* docs: improve comments in flinkSqlLexer
This commit is contained in:
Hayden 2023-05-19 14:28:25 +08:00 committed by GitHub
parent a026ae0592
commit 40c911597b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 12652 additions and 11856 deletions

View File

@ -9,320 +9,379 @@ LINE_COMMENT: (
| '--' ('\r'? '\n' | EOF) | '--' ('\r'? '\n' | EOF)
) -> channel(HIDDEN); ) -> channel(HIDDEN);
// List of keywords that are not reserved.
// Please keep the keyword in alphabetical order if new keyword is added.
// Please add it to the nonReservedKeywords rule if new keyword is added.
// Reference link https://github.com/apache/flink/blob/release-1.16/flink-table/flink-sql-parser/src/main/codegen/data/Parser.tdd
// Common Keywords KW_ADD: 'ADD';
KW_ADMIN: 'ADMIN';
KW_AFTER: 'AFTER';
KW_ANALYZE: 'ANALYZE';
KW_ASC: 'ASC';
KW_BEFORE: 'BEFORE';
KW_BYTES: 'BYTES';
KW_CASCADE: 'CASCADE';
KW_CATALOG: 'CATALOG';
KW_CATALOGS: 'CATALOGS';
KW_CENTURY: 'CENTURY';
KW_CHAIN: 'CHAIN';
KW_CHANGELOG_MODE: 'CHANGELOG_MODE';
KW_CHARACTERS: 'CHARACTERS';
KW_COMMENT: 'COMMENT';
KW_COMPACT: 'COMPACT';
KW_COLUMNS: 'COLUMNS';
KW_CONSTRAINTS: 'CONSTRAINTS';
KW_CONSTRUCTOR: 'CONSTRUCTOR';
KW_CUMULATE: 'CUMULATE';
KW_DATA: 'DATA';
KW_DATABASE: 'DATABASE';
KW_DATABASES: 'DATABASES';
KW_DAYS: 'DAYS';
KW_DECADE: 'DECADE';
KW_DEFINED: 'DEFINED';
KW_DESC: 'DESC';
KW_DESCRIPTOR: 'DESCRIPTOR';
KW_DIV: 'DIV';
KW_ENCODING: 'ENCODING';
KW_ENFORCED: 'ENFORCED';
KW_ENGINE: 'ENGINE';
KW_ERROR: 'ERROR';
KW_ESTIMATED_COST: 'ESTIMATED_COST';
KW_EXCEPTION: 'EXCEPTION';
KW_EXCLUDE: 'EXCLUDE';
KW_EXCLUDING: 'EXCLUDING';
KW_EXTENDED: 'EXTENDED';
KW_FILE: 'FILE';
KW_FINAL: 'FINAL';
KW_FIRST: 'FIRST';
KW_FOLLOWING: 'FOLLOWING';
KW_FORMAT: 'FORMAT';
KW_FORTRAN: 'FORTRAN';
KW_FOUND: 'FOUND';
KW_FRAC_SECOND: 'FRAC_SECOND';
KW_FUNCTIONS: 'FUNCTIONS';
KW_GENERAL: 'GENERAL';
KW_GENERATED: 'GENERATED';
KW_GO: 'GO';
KW_GOTO: 'GOTO';
KW_GRANTED: 'GRANTED';
KW_HOP: 'HOP';
KW_HOURS: 'HOURS';
KW_IF: 'IF';
KW_IGNORE: 'IGNORE';
KW_INCREMENT: 'INCREMENT';
KW_INPUT: 'INPUT';
KW_INVOKER: 'INVOKER';
KW_JAR: 'JAR';
KW_JARS: 'JARS';
KW_JAVA: 'JAVA';
KW_JSON: 'JSON';
KW_JSON_EXECUTION_PLAN: 'JSON_EXECUTION_PLAN';
KW_KEY: 'KEY';
KW_KEY_MEMBER: 'KEY_MEMBER';
KW_KEY_TYPE: 'KEY_TYPE';
KW_LABEL: 'LABEL';
KW_LAST: 'LAST';
KW_LENGTH: 'LENGTH';
KW_LEVEL: 'LEVEL';
KW_LOAD: 'LOAD';
KW_MAP: 'MAP';
KW_MICROSECOND: 'MICROSECOND';
KW_MILLENNIUM: 'MILLENNIUM';
KW_MILLISECOND: 'MILLISECOND';
KW_MINUTES: 'MINUTES';
KW_MINVALUE: 'MINVALUE';
KW_MODIFY: 'MODIFY';
KW_MODULES: 'MODULES';
KW_MONTHS: 'MONTHS';
KW_NANOSECOND: 'NANOSECOND';
KW_NULLS: 'NULLS';
KW_NUMBER: 'NUMBER';
KW_OPTION: 'OPTION';
KW_OPTIONS: 'OPTIONS';
KW_ORDERING: 'ORDERING';
KW_OUTPUT: 'OUTPUT';
KW_OVERWRITE: 'OVERWRITE';
KW_OVERWRITING: 'OVERWRITING';
KW_PARTITIONED: 'PARTITIONED';
KW_PARTITIONS: 'PARTITIONS';
KW_PASSING: 'PASSING';
KW_PAST: 'PAST';
KW_PATH: 'PATH';
KW_PLACING: 'PLACING';
KW_PLAN: 'PLAN';
KW_PRECEDING: 'PRECEDING';
KW_PRESERVE: 'PRESERVE';
KW_PRIOR: 'PRIOR';
KW_PRIVILEGES: 'PRIVILEGES';
KW_PUBLIC: 'PUBLIC';
KW_PYTHON: 'PYTHON';
KW_PYTHON_FILES: 'PYTHON_FILES';
KW_PYTHON_REQUIREMENTS: 'PYTHON_REQUIREMENTS';
KW_PYTHON_DEPENDENCIES: 'PYTHON_DEPENDENCIES';
KW_PYTHON_JAR: 'PYTHON_JAR';
KW_PYTHON_ARCHIVES: 'PYTHON_ARCHIVES';
KW_PYTHON_PARAMETER: 'PYTHON_PARAMETER';
KW_QUARTER: 'QUARTER';
KW_RAW: 'RAW';
KW_READ: 'READ';
KW_RELATIVE: 'RELATIVE';
KW_REMOVE: 'REMOVE';
KW_RENAME: 'RENAME';
KW_REPLACE: 'REPLACE';
KW_RESPECT: 'RESPECT';
KW_RESTART: 'RESTART';
KW_RESTRICT: 'RESTRICT';
KW_ROLE: 'ROLE';
KW_ROW_COUNT: 'ROW_COUNT';
KW_SCALA: 'SCALA';
KW_SCALAR: 'SCALAR';
KW_SCALE: 'SCALE';
KW_SCHEMA: 'SCHEMA';
KW_SECONDS: 'SECONDS';
KW_SECTION: 'SECTION';
KW_SECURITY: 'SECURITY';
KW_SELF: 'SELF';
KW_SERVER: 'SERVER';
KW_SERVER_NAME: 'SERVER_NAME';
KW_SESSION: 'SESSION';
KW_SETS: 'SETS';
KW_SIMPLE: 'SIMPLE';
KW_SIZE: 'SIZE';
KW_SLIDE: 'SLIDE';
KW_SOURCE: 'SOURCE';
KW_SPACE: 'SPACE';
KW_STATE: 'STATE';
KW_STATEMENT: 'STATEMENT';
KW_STEP: 'STEP';
KW_STRING: 'STRING';
KW_STRUCTURE: 'STRUCTURE';
KW_STYLE: 'STYLE';
KW_TABLES: 'TABLES';
KW_TEMPORARY: 'TEMPORARY';
KW_TIMECOL: 'TIMECOL';
KW_TIMESTAMP_LTZ: 'TIMESTAMP_LTZ';
KW_TIMESTAMPADD: 'TIMESTAMPADD';
KW_TIMESTAMPDIFF: 'TIMESTAMPDIFF';
KW_TRANSFORM: 'TRANSFORM';
KW_TUMBLE: 'TUMBLE';
KW_TYPE: 'TYPE';
KW_UNDER: 'UNDER';
KW_UNLOAD: 'UNLOAD';
KW_USAGE: 'USAGE';
KW_USE: 'USE';
KW_UTF16: 'UTF16';
KW_UTF32: 'UTF32';
KW_UTF8: 'UTF8';
KW_VERSION: 'VERSION';
KW_VIEW: 'VIEW';
KW_VIEWS: 'VIEWS';
KW_VIRTUAL: 'VIRTUAL';
KW_WATERMARK: 'WATERMARK';
KW_WATERMARKS: 'WATERMARKS';
KW_WEEK: 'WEEK';
KW_WORK: 'WORK';
KW_WRAPPER: 'WRAPPER';
KW_YEARS: 'YEARS';
KW_ZONE: 'ZONE';
SELECT: 'SELECT';
FROM: 'FROM'; // Reserved Keywords
ADD: 'ADD'; // Please keep the keyword in alphabetical order if new keyword is added.
AS: 'AS'; // Please add it to the reservedKeywords rule if new keyword is added.
ALL: 'ALL'; // Reference link https://calcite.apache.org/docs/reference.html
ANY: 'ANY';
DISTINCT: 'DISTINCT'; KW_ABS: 'ABS';
WHERE: 'WHERE'; KW_ALL: 'ALL';
GROUP: 'GROUP'; ALLOW: 'ALLOW';
BY: 'BY'; KW_ALTER : 'ALTER';
GROUPING: 'GROUPING'; KW_AND: 'AND';
SETS: 'SETS'; KW_ANY: 'ANY';
CUBE: 'CUBE'; KW_ARE: 'ARE';
ROLLUP: 'ROLLUP'; KW_ARRAY: 'ARRAY';
ORDER: 'ORDER'; KW_AS: 'AS';
HAVING: 'HAVING'; KW_AT: 'AT';
LIMIT: 'LIMIT'; KW_AVG: 'AVG';
AT: 'AT'; KW_BEGIN: 'BEGIN';
OR: 'OR'; KW_BETWEEN: 'BETWEEN';
AND: 'AND'; KW_BIGINT: 'BIGINT';
IN: 'IN'; KW_BINARY: 'BINARY';
NOT: 'NOT'; KW_BIT: 'BIT';
NO: 'NO'; KW_BLOB: 'BLOB';
EXISTS: 'EXISTS'; KW_BOOLEAN: 'BOOLEAN';
BETWEEN: 'BETWEEN'; KW_BOTH: 'BOTH';
LIKE: 'LIKE'; KW_BY: 'BY';
RLIKE: 'RLIKE'; KW_CALL: 'CALL';
IS: 'IS'; KW_CALLED: 'CALLED';
TRUE: 'TRUE'; KW_CASCADED: 'CASCADED';
FALSE: 'FALSE'; KW_CASE: 'CASE';
NULLS: 'NULLS'; KW_CAST: 'CAST';
ASC: 'ASC'; KW_CEIL: 'CEIL';
DESC: 'DESC'; KW_CHAR: 'CHAR';
FOR: 'FOR'; KW_CHARACTER: 'CHARACTER';
INTERVAL: 'INTERVAL'; KW_CHECK: 'CHECK';
CASE: 'CASE'; KW_CLOB: 'CLOB';
WHEN: 'WHEN'; KW_CLOSE: 'CLOSE';
THEN: 'THEN'; KW_COALESCE: 'COALESCE';
ELSE: 'ELSE'; KW_COLLATE: 'COLLATE';
BEGIN: 'BEGIN'; KW_COLLECT: 'COLLECT';
END: 'END'; KW_COLUMN: 'COLUMN';
JOIN: 'JOIN'; KW_COMMIT: 'COMMIT';
CROSS: 'CROSS'; KW_CONNECT: 'CONNECT';
OUTER: 'OUTER'; KW_CONSTRAINT: 'CONSTRAINT';
INNER: 'INNER'; KW_CONTAINS: 'CONTAINS';
LEFT: 'LEFT'; KW_CONVERT: 'CONVERT';
SEMI: 'SEMI'; KW_COUNT: 'COUNT';
RIGHT: 'RIGHT'; KW_CREATE: 'CREATE';
FULL: 'FULL'; KW_CROSS: 'CROSS';
USER: 'USER'; KW_CUBE: 'CUBE';
NATURAL: 'NATURAL'; KW_CURRENT: 'CURRENT';
ON: 'ON'; KW_CURSOR: 'CURSOR';
PIVOT: 'PIVOT'; KW_CYCLE: 'CYCLE';
LATERAL: 'LATERAL'; KW_DATE: 'DATE';
WINDOW: 'WINDOW'; KW_DATETIME: 'DATETIME';
OVER: 'OVER'; KW_DAY: 'DAY';
PARTITION: 'PARTITION'; KW_DEC: 'DEC';
RANGE: 'RANGE'; KW_DECIMAL: 'DECIMAL';
ROWS: 'ROWS'; KW_DECLARE: 'DECLARE';
UNBOUNDED: 'UNBOUNDED'; KW_DEFAULT: 'DEFAULT';
PRECEDING: 'PRECEDING'; KW_DEFINE: 'DEFINE';
FOLLOWING: 'FOLLOWING'; KW_DELETE: 'DELETE';
CURRENT: 'CURRENT'; KW_DESCRIBE: 'DESCRIBE';
FIRST: 'FIRST'; KW_DISTINCT: 'DISTINCT';
AFTER: 'AFTER'; KW_DOUBLE: 'DOUBLE';
LAST: 'LAST'; KW_DROP: 'DROP';
WITH: 'WITH'; KW_EACH: 'EACH';
WITHOUT: 'WITHOUT'; KW_ELSE: 'ELSE';
VALUES: 'VALUES'; KW_END: 'END';
CREATE: 'CREATE'; KW_EQUALS: 'EQUALS';
TABLE: 'TABLE'; KW_EXCEPT: 'EXCEPT';
DIRECTORY: 'DIRECTORY'; KW_EXECUTE: 'EXECUTE';
VIEW: 'VIEW'; KW_EXISTS: 'EXISTS';
REPLACE: 'REPLACE'; KW_EXPLAIN: 'EXPLAIN';
EXECUTE: 'EXECUTE'; KW_EXTERNAL: 'EXTERNAL';
STATEMENT: 'STATEMENT'; KW_EXTRACT: 'EXTRACT';
INSERT: 'INSERT'; KW_FALSE: 'FALSE';
DELETE: 'DELETE'; KW_FLOAT: 'FLOAT';
REMOVE: 'REMOVE'; KW_FOR: 'FOR';
INTO: 'INTO'; KW_FROM: 'FROM';
DESCRIBE: 'DESCRIBE'; KW_FULL: 'FULL';
EXPLAIN: 'EXPLAIN'; KW_FUNCTION: 'FUNCTION';
PLAN: 'PLAN'; KW_GLOBAL: 'GLOBAL';
CHANGELOG_MODE: 'CHANGELOG_MODE'; KW_GRANT: 'GRANT';
JSON_EXECUTION_PLAN: 'JSON_EXECUTION_PLAN'; KW_GROUP: 'GROUP';
ESTIMATED_COST: 'ESTIMATED_COST'; KW_GROUPING: 'GROUPING';
FORMAT: 'FORMAT'; KW_GROUPS: 'GROUPS';
LOGICAL: 'LOGICAL'; KW_HAVING: 'HAVING';
CODEGEN: 'CODEGEN'; KW_HOUR: 'HOUR';
COST: 'COST'; KW_IMPORT: 'IMPORT';
CAST: 'CAST'; KW_IN: 'IN';
SHOW: 'SHOW'; KW_INCLUDING: 'INCLUDING';
TABLES: 'TABLES'; KW_INNER: 'INNER';
COLUMNS: 'COLUMNS'; KW_INOUT: 'INOUT';
COLUMN: 'COLUMN'; KW_INSERT: 'INSERT';
USE: 'USE'; KW_INT: 'INT';
MODULE: 'MODULE'; KW_INTEGER: 'INTEGER';
MODULES: 'MODULES'; KW_INTERSECT: 'INTERSECT';
PARTITIONS: 'PARTITIONS'; KW_INTERVAL: 'INTERVAL';
FUNCTIONS: 'FUNCTIONS'; KW_INTO: 'INTO';
DROP: 'DROP'; KW_IS: 'IS';
UNION: 'UNION'; KW_JOIN: 'JOIN';
EXCEPT: 'EXCEPT'; KW_LAG: 'LAG';
SETMINUS: 'SETMINUS'; KW_LANGUAGE: 'LANGUAGE';
INTERSECT: 'INTERSECT'; KW_LATERAL: 'LATERAL';
TO: 'TO'; KW_LEADING: 'LEADING';
TABLESAMPLE: 'TABLESAMPLE'; KW_LEFT: 'LEFT';
STRATIFY: 'STRATIFY'; KW_LIKE: 'LIKE';
ALTER: 'ALTER'; KW_LIMIT: 'LIMIT';
RENAME: 'RENAME'; KW_LOCAL: 'LOCAL';
STRUCT: 'STRUCT'; KW_MATCH: 'MATCH';
COMMENT: 'COMMENT'; KW_MATCH_RECOGNIZE: 'MATCH_RECOGNIZE';
SET: 'SET'; KW_MEASURES: 'MEASURES';
RESET: 'RESET'; KW_MERGE: 'MERGE';
DATA: 'DATA'; KW_METADATA: 'METADATA';
START: 'START'; KW_MINUS: 'MINUS';
TRANSACTION: 'TRANSACTION'; KW_MINUTE: 'MINUTE';
COMMIT: 'COMMIT'; KW_MODIFIES: 'MODIFIES';
ROLLBACK: 'ROLLBACK'; KW_MODULE: 'MODULE';
MACRO: 'MACRO'; KW_MONTH: 'MONTH';
IGNORE: 'IGNORE'; KW_MULTISET: 'MULTISET';
BOTH: 'BOTH'; KW_NATURAL: 'NATURAL';
LEADING: 'LEADING'; KW_NEXT: 'NEXT';
TRAILING: 'TRAILING'; KW_NO: 'NO';
IF: 'IF'; KW_NONE: 'NONE';
POSITION: 'POSITION'; KW_NOT: 'NOT';
EXTRACT: 'EXTRACT'; KW_NULL: 'NULL';
MINUS: 'MINUS'; KW_NUMERIC: 'NUMERIC';
DIV: 'DIV'; KW_OF: 'OF';
PERCENTLIT: 'PERCENTLIT'; KW_OFFSET: 'OFFSET';
BUCKET: 'BUCKET'; KW_ON: 'ON';
OUT: 'OUT'; KW_ONE: 'ONE';
OF: 'OF'; KW_OR: 'OR';
SORT: 'SORT'; KW_ORDER: 'ORDER';
CLUSTER: 'CLUSTER'; KW_OUT: 'OUT';
DISTRIBUTE: 'DISTRIBUTE'; KW_OUTER: 'OUTER';
OVERWRITE: 'OVERWRITE'; KW_OVER: 'OVER';
TRANSFORM: 'TRANSFORM'; KW_OVERLAY: 'OVERLAY';
REDUCE: 'REDUCE'; KW_PARTITION: 'PARTITION';
USING: 'USING'; KW_PATTERN: 'PATTERN';
SERDE: 'SERDE'; KW_PER: 'PER';
SERDEPROPERTIES: 'SERDEPROPERTIES'; KW_PERCENT: 'PERCENT';
RECORDREADER: 'RECORDREADER'; KW_PERIOD: 'PERIOD';
RECORDWRITER: 'RECORDWRITER'; KW_POSITION: 'POSITION';
DELIMITED: 'DELIMITED'; KW_PRIMARY: 'PRIMARY';
FIELDS: 'FIELDS'; KW_RANGE: 'RANGE';
TERMINATED: 'TERMINATED'; KW_RANK: 'RANK';
COLLECTION: 'COLLECTION'; KW_RESET: 'RESET';
ITEMS: 'ITEMS'; KW_REVOKE: 'REVOKE';
KEYS: 'KEYS'; KW_RIGHT: 'RIGHT';
ESCAPED: 'ESCAPED'; KW_RLIKE: 'RLIKE';
LINES: 'LINES'; KW_ROLLBACK: 'ROLLBACK';
SEPARATED: 'SEPARATED'; KW_ROLLUP: 'ROLLUP';
FUNCTION: 'FUNCTION'; KW_ROW: 'ROW';
EXTENDED: 'EXTENDED'; KW_ROWS: 'ROWS';
REFRESH: 'REFRESH'; KW_SECOND: 'SECOND';
CLEAR: 'CLEAR'; KW_SELECT: 'SELECT';
CACHE: 'CACHE'; KW_SET: 'SET';
UNCACHE: 'UNCACHE'; KW_SHOW: 'SHOW';
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';
CONSTRAINT: 'CONSTRAINT';
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';
UNLOAD: 'UNLOAD';
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: 'MATCH';
NEXT: 'NEXT';
WITHIN: 'WITHIN';
WS: 'WS';
SYSTEM: 'SYSTEM';
INCLUDING: 'INCLUDING';
EXCLUDING: 'EXCLUDING';
OVERWRITING: 'OVERWRITING';
CONSTRAINTS: 'CONSTRAINTS';
GENERATED: 'GENERATED';
WATERMARKS: 'WATERMARKS';
CATALOG: 'CATALOG';
LANGUAGE: 'LANGUAGE';
JAVA: 'JAVA';
SCALA: 'SCALA';
PYTHON: 'PYTHON';
JAR: 'JAR';
FILE: 'FILE';
PYTHON_FILES: 'PYTHON_FILES';
PYTHON_REQUIREMENTS: 'PYTHON_REQUIREMENTS';
PYTHON_DEPENDENCIES: 'PYTHON_DEPENDENCIES';
PYTHON_JAR: 'PYTHON_JAR';
PYTHON_ARCHIVES: 'PYTHON_ARCHIVES';
PYTHON_PARAMETER: 'PYTHON_PARAMETER';
ENGINE: 'ENGINE';
CATALOGS: 'CATALOGS';
VIEWS: 'VIEWS';
JARS: 'JARS';
PRIMARY: 'PRIMARY';
UNIQUE: 'UNIQUE';
KEY: 'KEY';
PERIOD: 'PERIOD';
SYSTEM_TIME: 'SYSTEM_TIME';
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'; KW_SKIP: 'SKIP';
PAST: 'PAST'; KW_SMALLINT: 'SMALLINT';
DEFINE: 'DEFINE'; KW_START: 'START';
KW_STATIC: 'STATIC';
// DATA TYPE Keywords KW_SUBSTRING: 'SUBSTRING';
KW_SUM: 'SUM';
STRING: 'STRING'; KW_SYSTEM: 'SYSTEM';
ARRAY: 'ARRAY'; KW_SYSTEM_TIME: 'SYSTEM_TIME';
MAP: 'MAP'; KW_SYSTEM_USER: 'SYSTEM_USER';
CHAR: 'CHAR'; KW_TABLE: 'TABLE';
VARCHAR: 'VARCHAR'; KW_TABLESAMPLE: 'TABLESAMPLE';
BINARY: 'BINARY'; KW_THEN: 'THEN';
VARBINARY: 'VARBINARY'; KW_TIME: 'TIME';
BYTES: 'BYTES'; KW_TIMESTAMP: 'TIMESTAMP';
DECIMAL: 'DECIMAL'; KW_TINYINT: 'TINYINT';
DEC: 'DEC'; KW_TO: 'TO';
NUMERIC: 'NUMERIC'; KW_TRUE: 'TRUE';
TINYINT: 'TINYINT'; KW_TRUNCATE: 'TRUNCATE';
SMALLINT: 'SMALLINT'; KW_UNION: 'UNION';
INT: 'INT'; KW_UNIQUE: 'UNIQUE';
INTEGER: 'INTEGER'; KW_UNKNOWN: 'UNKNOWN';
BIGINT: 'BIGINT'; KW_UNNEST: 'UNNEST';
FLOAT: 'FLOAT'; KW_UPPER: 'UPPER';
DOUBLE: 'DOUBLE'; KW_UPSERT: 'UPSERT';
DATE: 'DATE'; KW_USER: 'USER';
TIME: 'TIME'; KW_USING: 'USING';
TIMESTAMP: 'TIMESTAMP'; KW_VALUE: 'VALUE';
TIMESTAMP_LTZ: 'TIMESTAMP_LTZ'; KW_VALUES: 'VALUES';
MULTISET: 'MULTISET'; KW_VARBINARY: 'VARBINARY';
BOOLEAN: 'BOOLEAN'; KW_VARCHAR: 'VARCHAR';
RAW: 'RAW'; KW_WHEN: 'WHEN';
ROW: 'ROW'; KW_WHERE: 'WHERE';
NULL: 'NULL'; KW_WINDOW: 'WINDOW';
DATETIME: 'DATETIME'; // 数栈自定义类型 KW_WITH: 'WITH';
KW_WITHIN: 'WITHIN';
KW_WITHOUT: 'WITHOUT';
KW_YEAR: 'YEAR';
// Operators. Comparation // Operators. Comparation
@ -366,7 +425,7 @@ DOUBLE_VERTICAL_SIGN: '||';
DOUBLE_HYPNEN_SIGN: '--'; DOUBLE_HYPNEN_SIGN: '--';
SLASH_SIGN: '/'; SLASH_SIGN: '/';
QUESTION_MARK_SIGN: '?'; QUESTION_MARK_SIGN: '?';
DOT_ID: '.' ID_LITERAL_FRAG; DOUBLE_RIGHT_ARROW: '=>';
STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING; STRING_LITERAL: DQUOTA_STRING | SQUOTA_STRING | BQUOTA_STRING;
DIG_LITERAL: DEC_DIGIT+; DIG_LITERAL: DEC_DIGIT+;
REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+ REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
@ -376,7 +435,6 @@ REAL_LITERAL: (DEC_DIGIT+)? '.' DEC_DIGIT+
BIT_STRING: BIT_STRING_L; BIT_STRING: BIT_STRING_L;
ID_LITERAL: ID_LITERAL_FRAG; ID_LITERAL: ID_LITERAL_FRAG;
FILE_PATH: FILE_PATH_STRING; FILE_PATH: FILE_PATH_STRING;
DOUBLE_ARROW: '=>';
fragment FILE_PATH_STRING: ([/\\] (~([/\\ ]))*)+; fragment FILE_PATH_STRING: ([/\\] (~([/\\ ]))*)+;
fragment JAR_FILE_PARTTARN: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`'; fragment JAR_FILE_PARTTARN: '`' ( '\\'. | '``' | ~('`'|'\\'))* '`';

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

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

File diff suppressed because it is too large Load Diff

View File

@ -133,7 +133,6 @@ import { PatternVariablesDefinationContext } from "./FlinkSqlParser";
import { WindowFrameContext } from "./FlinkSqlParser"; import { WindowFrameContext } from "./FlinkSqlParser";
import { FrameBoundContext } from "./FlinkSqlParser"; import { FrameBoundContext } from "./FlinkSqlParser";
import { WithinClauseContext } from "./FlinkSqlParser"; import { WithinClauseContext } from "./FlinkSqlParser";
import { TimeIntervalExpressionContext } from "./FlinkSqlParser";
import { ExpressionContext } from "./FlinkSqlParser"; import { ExpressionContext } from "./FlinkSqlParser";
import { LogicalNotContext } from "./FlinkSqlParser"; import { LogicalNotContext } from "./FlinkSqlParser";
import { PredicatedContext } from "./FlinkSqlParser"; import { PredicatedContext } from "./FlinkSqlParser";
@ -163,12 +162,13 @@ import { FunctionNameContext } from "./FlinkSqlParser";
import { DereferenceDefinitionContext } from "./FlinkSqlParser"; import { DereferenceDefinitionContext } from "./FlinkSqlParser";
import { CorrelationNameContext } from "./FlinkSqlParser"; import { CorrelationNameContext } from "./FlinkSqlParser";
import { QualifiedNameContext } from "./FlinkSqlParser"; import { QualifiedNameContext } from "./FlinkSqlParser";
import { IntervalContext } from "./FlinkSqlParser"; import { TimeIntervalExpressionContext } from "./FlinkSqlParser";
import { ErrorCapturingMultiUnitsIntervalContext } from "./FlinkSqlParser"; import { ErrorCapturingMultiUnitsIntervalContext } from "./FlinkSqlParser";
import { MultiUnitsIntervalContext } from "./FlinkSqlParser"; import { MultiUnitsIntervalContext } from "./FlinkSqlParser";
import { ErrorCapturingUnitToUnitIntervalContext } from "./FlinkSqlParser"; import { ErrorCapturingUnitToUnitIntervalContext } from "./FlinkSqlParser";
import { UnitToUnitIntervalContext } from "./FlinkSqlParser"; import { UnitToUnitIntervalContext } from "./FlinkSqlParser";
import { IntervalValueContext } from "./FlinkSqlParser"; import { IntervalValueContext } from "./FlinkSqlParser";
import { IntervalTimeUnitContext } from "./FlinkSqlParser";
import { ColumnAliasContext } from "./FlinkSqlParser"; import { ColumnAliasContext } from "./FlinkSqlParser";
import { TableAliasContext } from "./FlinkSqlParser"; import { TableAliasContext } from "./FlinkSqlParser";
import { ErrorCapturingIdentifierContext } from "./FlinkSqlParser"; import { ErrorCapturingIdentifierContext } from "./FlinkSqlParser";
@ -176,15 +176,12 @@ import { ErrorIdentContext } from "./FlinkSqlParser";
import { RealIdentContext } from "./FlinkSqlParser"; import { RealIdentContext } from "./FlinkSqlParser";
import { IdentifierListContext } from "./FlinkSqlParser"; import { IdentifierListContext } from "./FlinkSqlParser";
import { IdentifierSeqContext } from "./FlinkSqlParser"; import { IdentifierSeqContext } from "./FlinkSqlParser";
import { IdentifierContext } from "./FlinkSqlParser";
import { UnquotedIdentifierAlternativeContext } from "./FlinkSqlParser"; import { UnquotedIdentifierAlternativeContext } from "./FlinkSqlParser";
import { QuotedIdentifierAlternativeContext } from "./FlinkSqlParser"; import { QuotedIdentifierAlternativeContext } from "./FlinkSqlParser";
import { AnsiNonReservedKeywordsContext } from "./FlinkSqlParser"; import { NonReservedKeywordsAlternativeContext } from "./FlinkSqlParser";
import { NonReservedKeywordsContext } from "./FlinkSqlParser";
import { UnquotedIdentifierContext } from "./FlinkSqlParser"; import { UnquotedIdentifierContext } from "./FlinkSqlParser";
import { QuotedIdentifierContext } from "./FlinkSqlParser"; import { QuotedIdentifierContext } from "./FlinkSqlParser";
import { WhenClauseContext } from "./FlinkSqlParser"; import { WhenClauseContext } from "./FlinkSqlParser";
import { UidListContext } from "./FlinkSqlParser";
import { UidContext } from "./FlinkSqlParser"; import { UidContext } from "./FlinkSqlParser";
import { WithOptionContext } from "./FlinkSqlParser"; import { WithOptionContext } from "./FlinkSqlParser";
import { IfNotExistsContext } from "./FlinkSqlParser"; import { IfNotExistsContext } from "./FlinkSqlParser";
@ -198,15 +195,13 @@ import { ComparisonOperatorContext } from "./FlinkSqlParser";
import { BitOperatorContext } from "./FlinkSqlParser"; import { BitOperatorContext } from "./FlinkSqlParser";
import { MathOperatorContext } from "./FlinkSqlParser"; import { MathOperatorContext } from "./FlinkSqlParser";
import { UnaryOperatorContext } from "./FlinkSqlParser"; import { UnaryOperatorContext } from "./FlinkSqlParser";
import { FullColumnNameContext } from "./FlinkSqlParser";
import { ConstantContext } from "./FlinkSqlParser"; import { ConstantContext } from "./FlinkSqlParser";
import { StringLiteralContext } from "./FlinkSqlParser"; import { StringLiteralContext } from "./FlinkSqlParser";
import { DecimalLiteralContext } from "./FlinkSqlParser"; import { DecimalLiteralContext } from "./FlinkSqlParser";
import { BooleanLiteralContext } from "./FlinkSqlParser"; import { BooleanLiteralContext } from "./FlinkSqlParser";
import { SetQuantifierContext } from "./FlinkSqlParser"; import { SetQuantifierContext } from "./FlinkSqlParser";
import { AnsiNonReservedContext } from "./FlinkSqlParser"; import { ReservedKeywordsContext } from "./FlinkSqlParser";
import { StrictNonReservedContext } from "./FlinkSqlParser"; import { NonReservedKeywordsContext } from "./FlinkSqlParser";
import { NonReservedContext } from "./FlinkSqlParser";
/** /**
@ -1518,16 +1513,6 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitWithinClause?: (ctx: WithinClauseContext) => void; 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`. * Enter a parse tree produced by `FlinkSqlParser.expression`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1863,15 +1848,15 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
*/ */
exitQualifiedName?: (ctx: QualifiedNameContext) => void; exitQualifiedName?: (ctx: QualifiedNameContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.interval`. * Enter a parse tree produced by `FlinkSqlParser.timeIntervalExpression`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
enterInterval?: (ctx: IntervalContext) => void; enterTimeIntervalExpression?: (ctx: TimeIntervalExpressionContext) => void;
/** /**
* Exit a parse tree produced by `FlinkSqlParser.interval`. * Exit a parse tree produced by `FlinkSqlParser.timeIntervalExpression`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitInterval?: (ctx: IntervalContext) => void; exitTimeIntervalExpression?: (ctx: TimeIntervalExpressionContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.errorCapturingMultiUnitsInterval`. * Enter a parse tree produced by `FlinkSqlParser.errorCapturingMultiUnitsInterval`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1922,6 +1907,16 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitIntervalValue?: (ctx: IntervalValueContext) => void; exitIntervalValue?: (ctx: IntervalValueContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.intervalTimeUnit`.
* @param ctx the parse tree
*/
enterIntervalTimeUnit?: (ctx: IntervalTimeUnitContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.intervalTimeUnit`.
* @param ctx the parse tree
*/
exitIntervalTimeUnit?: (ctx: IntervalTimeUnitContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.columnAlias`. * Enter a parse tree produced by `FlinkSqlParser.columnAlias`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1996,64 +1991,42 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitIdentifierSeq?: (ctx: IdentifierSeqContext) => void; exitIdentifierSeq?: (ctx: IdentifierSeqContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.identifier`.
* @param ctx the parse tree
*/
enterIdentifier?: (ctx: IdentifierContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.identifier`.
* @param ctx the parse tree
*/
exitIdentifier?: (ctx: IdentifierContext) => void;
/** /**
* Enter a parse tree produced by the `unquotedIdentifierAlternative` * Enter a parse tree produced by the `unquotedIdentifierAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
enterUnquotedIdentifierAlternative?: (ctx: UnquotedIdentifierAlternativeContext) => void; enterUnquotedIdentifierAlternative?: (ctx: UnquotedIdentifierAlternativeContext) => void;
/** /**
* Exit a parse tree produced by the `unquotedIdentifierAlternative` * Exit a parse tree produced by the `unquotedIdentifierAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitUnquotedIdentifierAlternative?: (ctx: UnquotedIdentifierAlternativeContext) => void; exitUnquotedIdentifierAlternative?: (ctx: UnquotedIdentifierAlternativeContext) => void;
/** /**
* Enter a parse tree produced by the `quotedIdentifierAlternative` * Enter a parse tree produced by the `quotedIdentifierAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
enterQuotedIdentifierAlternative?: (ctx: QuotedIdentifierAlternativeContext) => void; enterQuotedIdentifierAlternative?: (ctx: QuotedIdentifierAlternativeContext) => void;
/** /**
* Exit a parse tree produced by the `quotedIdentifierAlternative` * Exit a parse tree produced by the `quotedIdentifierAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitQuotedIdentifierAlternative?: (ctx: QuotedIdentifierAlternativeContext) => void; exitQuotedIdentifierAlternative?: (ctx: QuotedIdentifierAlternativeContext) => void;
/** /**
* Enter a parse tree produced by the `ansiNonReservedKeywords` * Enter a parse tree produced by the `nonReservedKeywordsAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
enterAnsiNonReservedKeywords?: (ctx: AnsiNonReservedKeywordsContext) => void; enterNonReservedKeywordsAlternative?: (ctx: NonReservedKeywordsAlternativeContext) => void;
/** /**
* Exit a parse tree produced by the `ansiNonReservedKeywords` * Exit a parse tree produced by the `nonReservedKeywordsAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitAnsiNonReservedKeywords?: (ctx: AnsiNonReservedKeywordsContext) => void; exitNonReservedKeywordsAlternative?: (ctx: NonReservedKeywordsAlternativeContext) => void;
/**
* Enter a parse tree produced by the `nonReservedKeywords`
* labeled alternative in `FlinkSqlParser.strictIdentifier`.
* @param ctx the parse tree
*/
enterNonReservedKeywords?: (ctx: NonReservedKeywordsContext) => void;
/**
* Exit a parse tree produced by the `nonReservedKeywords`
* labeled alternative in `FlinkSqlParser.strictIdentifier`.
* @param ctx the parse tree
*/
exitNonReservedKeywords?: (ctx: NonReservedKeywordsContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.unquotedIdentifier`. * Enter a parse tree produced by `FlinkSqlParser.unquotedIdentifier`.
* @param ctx the parse tree * @param ctx the parse tree
@ -2084,16 +2057,6 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitWhenClause?: (ctx: WhenClauseContext) => void; exitWhenClause?: (ctx: WhenClauseContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.uidList`.
* @param ctx the parse tree
*/
enterUidList?: (ctx: UidListContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.uidList`.
* @param ctx the parse tree
*/
exitUidList?: (ctx: UidListContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.uid`. * Enter a parse tree produced by `FlinkSqlParser.uid`.
* @param ctx the parse tree * @param ctx the parse tree
@ -2224,16 +2187,6 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitUnaryOperator?: (ctx: UnaryOperatorContext) => void; exitUnaryOperator?: (ctx: UnaryOperatorContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.fullColumnName`.
* @param ctx the parse tree
*/
enterFullColumnName?: (ctx: FullColumnNameContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.fullColumnName`.
* @param ctx the parse tree
*/
exitFullColumnName?: (ctx: FullColumnNameContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.constant`. * Enter a parse tree produced by `FlinkSqlParser.constant`.
* @param ctx the parse tree * @param ctx the parse tree
@ -2285,34 +2238,24 @@ export default class FlinkSqlParserListener extends ParseTreeListener {
*/ */
exitSetQuantifier?: (ctx: SetQuantifierContext) => void; exitSetQuantifier?: (ctx: SetQuantifierContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.ansiNonReserved`. * Enter a parse tree produced by `FlinkSqlParser.reservedKeywords`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
enterAnsiNonReserved?: (ctx: AnsiNonReservedContext) => void; enterReservedKeywords?: (ctx: ReservedKeywordsContext) => void;
/** /**
* Exit a parse tree produced by `FlinkSqlParser.ansiNonReserved`. * Exit a parse tree produced by `FlinkSqlParser.reservedKeywords`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitAnsiNonReserved?: (ctx: AnsiNonReservedContext) => void; exitReservedKeywords?: (ctx: ReservedKeywordsContext) => void;
/** /**
* Enter a parse tree produced by `FlinkSqlParser.strictNonReserved`. * Enter a parse tree produced by `FlinkSqlParser.nonReservedKeywords`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
enterStrictNonReserved?: (ctx: StrictNonReservedContext) => void; enterNonReservedKeywords?: (ctx: NonReservedKeywordsContext) => void;
/** /**
* Exit a parse tree produced by `FlinkSqlParser.strictNonReserved`. * Exit a parse tree produced by `FlinkSqlParser.nonReservedKeywords`.
* @param ctx the parse tree * @param ctx the parse tree
*/ */
exitStrictNonReserved?: (ctx: StrictNonReservedContext) => void; exitNonReservedKeywords?: (ctx: NonReservedKeywordsContext) => void;
/**
* Enter a parse tree produced by `FlinkSqlParser.nonReserved`.
* @param ctx the parse tree
*/
enterNonReserved?: (ctx: NonReservedContext) => void;
/**
* Exit a parse tree produced by `FlinkSqlParser.nonReserved`.
* @param ctx the parse tree
*/
exitNonReserved?: (ctx: NonReservedContext) => void;
} }

View File

@ -133,7 +133,6 @@ import { PatternVariablesDefinationContext } from "./FlinkSqlParser";
import { WindowFrameContext } from "./FlinkSqlParser"; import { WindowFrameContext } from "./FlinkSqlParser";
import { FrameBoundContext } from "./FlinkSqlParser"; import { FrameBoundContext } from "./FlinkSqlParser";
import { WithinClauseContext } from "./FlinkSqlParser"; import { WithinClauseContext } from "./FlinkSqlParser";
import { TimeIntervalExpressionContext } from "./FlinkSqlParser";
import { ExpressionContext } from "./FlinkSqlParser"; import { ExpressionContext } from "./FlinkSqlParser";
import { LogicalNotContext } from "./FlinkSqlParser"; import { LogicalNotContext } from "./FlinkSqlParser";
import { PredicatedContext } from "./FlinkSqlParser"; import { PredicatedContext } from "./FlinkSqlParser";
@ -163,12 +162,13 @@ import { FunctionNameContext } from "./FlinkSqlParser";
import { DereferenceDefinitionContext } from "./FlinkSqlParser"; import { DereferenceDefinitionContext } from "./FlinkSqlParser";
import { CorrelationNameContext } from "./FlinkSqlParser"; import { CorrelationNameContext } from "./FlinkSqlParser";
import { QualifiedNameContext } from "./FlinkSqlParser"; import { QualifiedNameContext } from "./FlinkSqlParser";
import { IntervalContext } from "./FlinkSqlParser"; import { TimeIntervalExpressionContext } from "./FlinkSqlParser";
import { ErrorCapturingMultiUnitsIntervalContext } from "./FlinkSqlParser"; import { ErrorCapturingMultiUnitsIntervalContext } from "./FlinkSqlParser";
import { MultiUnitsIntervalContext } from "./FlinkSqlParser"; import { MultiUnitsIntervalContext } from "./FlinkSqlParser";
import { ErrorCapturingUnitToUnitIntervalContext } from "./FlinkSqlParser"; import { ErrorCapturingUnitToUnitIntervalContext } from "./FlinkSqlParser";
import { UnitToUnitIntervalContext } from "./FlinkSqlParser"; import { UnitToUnitIntervalContext } from "./FlinkSqlParser";
import { IntervalValueContext } from "./FlinkSqlParser"; import { IntervalValueContext } from "./FlinkSqlParser";
import { IntervalTimeUnitContext } from "./FlinkSqlParser";
import { ColumnAliasContext } from "./FlinkSqlParser"; import { ColumnAliasContext } from "./FlinkSqlParser";
import { TableAliasContext } from "./FlinkSqlParser"; import { TableAliasContext } from "./FlinkSqlParser";
import { ErrorCapturingIdentifierContext } from "./FlinkSqlParser"; import { ErrorCapturingIdentifierContext } from "./FlinkSqlParser";
@ -176,15 +176,12 @@ import { ErrorIdentContext } from "./FlinkSqlParser";
import { RealIdentContext } from "./FlinkSqlParser"; import { RealIdentContext } from "./FlinkSqlParser";
import { IdentifierListContext } from "./FlinkSqlParser"; import { IdentifierListContext } from "./FlinkSqlParser";
import { IdentifierSeqContext } from "./FlinkSqlParser"; import { IdentifierSeqContext } from "./FlinkSqlParser";
import { IdentifierContext } from "./FlinkSqlParser";
import { UnquotedIdentifierAlternativeContext } from "./FlinkSqlParser"; import { UnquotedIdentifierAlternativeContext } from "./FlinkSqlParser";
import { QuotedIdentifierAlternativeContext } from "./FlinkSqlParser"; import { QuotedIdentifierAlternativeContext } from "./FlinkSqlParser";
import { AnsiNonReservedKeywordsContext } from "./FlinkSqlParser"; import { NonReservedKeywordsAlternativeContext } from "./FlinkSqlParser";
import { NonReservedKeywordsContext } from "./FlinkSqlParser";
import { UnquotedIdentifierContext } from "./FlinkSqlParser"; import { UnquotedIdentifierContext } from "./FlinkSqlParser";
import { QuotedIdentifierContext } from "./FlinkSqlParser"; import { QuotedIdentifierContext } from "./FlinkSqlParser";
import { WhenClauseContext } from "./FlinkSqlParser"; import { WhenClauseContext } from "./FlinkSqlParser";
import { UidListContext } from "./FlinkSqlParser";
import { UidContext } from "./FlinkSqlParser"; import { UidContext } from "./FlinkSqlParser";
import { WithOptionContext } from "./FlinkSqlParser"; import { WithOptionContext } from "./FlinkSqlParser";
import { IfNotExistsContext } from "./FlinkSqlParser"; import { IfNotExistsContext } from "./FlinkSqlParser";
@ -198,15 +195,13 @@ import { ComparisonOperatorContext } from "./FlinkSqlParser";
import { BitOperatorContext } from "./FlinkSqlParser"; import { BitOperatorContext } from "./FlinkSqlParser";
import { MathOperatorContext } from "./FlinkSqlParser"; import { MathOperatorContext } from "./FlinkSqlParser";
import { UnaryOperatorContext } from "./FlinkSqlParser"; import { UnaryOperatorContext } from "./FlinkSqlParser";
import { FullColumnNameContext } from "./FlinkSqlParser";
import { ConstantContext } from "./FlinkSqlParser"; import { ConstantContext } from "./FlinkSqlParser";
import { StringLiteralContext } from "./FlinkSqlParser"; import { StringLiteralContext } from "./FlinkSqlParser";
import { DecimalLiteralContext } from "./FlinkSqlParser"; import { DecimalLiteralContext } from "./FlinkSqlParser";
import { BooleanLiteralContext } from "./FlinkSqlParser"; import { BooleanLiteralContext } from "./FlinkSqlParser";
import { SetQuantifierContext } from "./FlinkSqlParser"; import { SetQuantifierContext } from "./FlinkSqlParser";
import { AnsiNonReservedContext } from "./FlinkSqlParser"; import { ReservedKeywordsContext } from "./FlinkSqlParser";
import { StrictNonReservedContext } from "./FlinkSqlParser"; import { NonReservedKeywordsContext } from "./FlinkSqlParser";
import { NonReservedContext } from "./FlinkSqlParser";
/** /**
@ -999,12 +994,6 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result * @return the visitor result
*/ */
visitWithinClause?: (ctx: WithinClauseContext) => 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`. * Visit a parse tree produced by `FlinkSqlParser.expression`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1202,11 +1191,11 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
*/ */
visitQualifiedName?: (ctx: QualifiedNameContext) => Result; visitQualifiedName?: (ctx: QualifiedNameContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.interval`. * Visit a parse tree produced by `FlinkSqlParser.timeIntervalExpression`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitInterval?: (ctx: IntervalContext) => Result; visitTimeIntervalExpression?: (ctx: TimeIntervalExpressionContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.errorCapturingMultiUnitsInterval`. * Visit a parse tree produced by `FlinkSqlParser.errorCapturingMultiUnitsInterval`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1237,6 +1226,12 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result * @return the visitor result
*/ */
visitIntervalValue?: (ctx: IntervalValueContext) => Result; visitIntervalValue?: (ctx: IntervalValueContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.intervalTimeUnit`.
* @param ctx the parse tree
* @return the visitor result
*/
visitIntervalTimeUnit?: (ctx: IntervalTimeUnitContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.columnAlias`. * Visit a parse tree produced by `FlinkSqlParser.columnAlias`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1281,40 +1276,27 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result * @return the visitor result
*/ */
visitIdentifierSeq?: (ctx: IdentifierSeqContext) => Result; visitIdentifierSeq?: (ctx: IdentifierSeqContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.identifier`.
* @param ctx the parse tree
* @return the visitor result
*/
visitIdentifier?: (ctx: IdentifierContext) => Result;
/** /**
* Visit a parse tree produced by the `unquotedIdentifierAlternative` * Visit a parse tree produced by the `unquotedIdentifierAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitUnquotedIdentifierAlternative?: (ctx: UnquotedIdentifierAlternativeContext) => Result; visitUnquotedIdentifierAlternative?: (ctx: UnquotedIdentifierAlternativeContext) => Result;
/** /**
* Visit a parse tree produced by the `quotedIdentifierAlternative` * Visit a parse tree produced by the `quotedIdentifierAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitQuotedIdentifierAlternative?: (ctx: QuotedIdentifierAlternativeContext) => Result; visitQuotedIdentifierAlternative?: (ctx: QuotedIdentifierAlternativeContext) => Result;
/** /**
* Visit a parse tree produced by the `ansiNonReservedKeywords` * Visit a parse tree produced by the `nonReservedKeywordsAlternative`
* labeled alternative in `FlinkSqlParser.strictIdentifier`. * labeled alternative in `FlinkSqlParser.identifier`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitAnsiNonReservedKeywords?: (ctx: AnsiNonReservedKeywordsContext) => Result; visitNonReservedKeywordsAlternative?: (ctx: NonReservedKeywordsAlternativeContext) => Result;
/**
* Visit a parse tree produced by the `nonReservedKeywords`
* labeled alternative in `FlinkSqlParser.strictIdentifier`.
* @param ctx the parse tree
* @return the visitor result
*/
visitNonReservedKeywords?: (ctx: NonReservedKeywordsContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.unquotedIdentifier`. * Visit a parse tree produced by `FlinkSqlParser.unquotedIdentifier`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1333,12 +1315,6 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result * @return the visitor result
*/ */
visitWhenClause?: (ctx: WhenClauseContext) => Result; visitWhenClause?: (ctx: WhenClauseContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.uidList`.
* @param ctx the parse tree
* @return the visitor result
*/
visitUidList?: (ctx: UidListContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.uid`. * Visit a parse tree produced by `FlinkSqlParser.uid`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1417,12 +1393,6 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
* @return the visitor result * @return the visitor result
*/ */
visitUnaryOperator?: (ctx: UnaryOperatorContext) => Result; visitUnaryOperator?: (ctx: UnaryOperatorContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.fullColumnName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitFullColumnName?: (ctx: FullColumnNameContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.constant`. * Visit a parse tree produced by `FlinkSqlParser.constant`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1454,22 +1424,16 @@ export default class FlinkSqlParserVisitor<Result> extends ParseTreeVisitor<Resu
*/ */
visitSetQuantifier?: (ctx: SetQuantifierContext) => Result; visitSetQuantifier?: (ctx: SetQuantifierContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.ansiNonReserved`. * Visit a parse tree produced by `FlinkSqlParser.reservedKeywords`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitAnsiNonReserved?: (ctx: AnsiNonReservedContext) => Result; visitReservedKeywords?: (ctx: ReservedKeywordsContext) => Result;
/** /**
* Visit a parse tree produced by `FlinkSqlParser.strictNonReserved`. * Visit a parse tree produced by `FlinkSqlParser.nonReservedKeywords`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitStrictNonReserved?: (ctx: StrictNonReservedContext) => Result; visitNonReservedKeywords?: (ctx: NonReservedKeywordsContext) => Result;
/**
* Visit a parse tree produced by `FlinkSqlParser.nonReserved`.
* @param ctx the parse tree
* @return the visitor result
*/
visitNonReserved?: (ctx: NonReservedContext) => Result;
} }

View File

@ -39,7 +39,7 @@ describe('FlinkSQL Syntax Tests', () => {
}); });
test('Test Select Statement with having clause', () => { test('Test Select Statement with having clause', () => {
const sql = ` const sql = `
SELECT city, sum(quantity) AS sum SELECT city, sum(quantity) AS _sum
FROM dealer GROUP BY city HAVING city = 'Fremont'; FROM dealer GROUP BY city HAVING city = 'Fremont';
`; `;
const result = parser.validate(sql); const result = parser.validate(sql);

View File

@ -1,3 +1,3 @@
ALTER DATABASE tempDB SET ("key1"="value1"); ALTER DATABASE tempDB SET ("key1"="value1");
alter database db1 set ('key1' = 'value1','key2.a' = 'value2.a'); ALTER DATABASE db1 SET ('key1' = 'value1','key2.a' = 'value2.a');

View File

@ -1,12 +1,12 @@
ALTER FUNCTION tempFunction AS 'SimpleUdf'; ALTER FUNCTION tempFunction AS 'SimpleUdf';
alter temporary function function1 as 'org.apache.flink.function.function1'; ALTER temporary FUNCTION function1 AS 'org.apache.flink.function.function1';
alter temporary function function1 as 'org.apache.flink.function.function1' language scala; ALTER temporary FUNCTION function1 AS 'org.apache.flink.function.function1' LANGUAGE scala;
alter temporary system function function1 as 'org.apache.flink.function.function1'; ALTER temporary SYSTEM FUNCTION function1 AS 'org.apache.flink.function.function1';
alter temporary system function function1 as 'org.apache.flink.function.function1' language java; ALTER temporary SYSTEM FUNCTION function1 AS 'org.apache.flink.function.function1' LANGUAGE java;
ALTER TEMPORARY SYSTEM FUNCTION IF EXISTS tempFunction AS 'SimpleUdf'; ALTER TEMPORARY SYSTEM FUNCTION IF EXISTS tempFunction AS 'SimpleUdf';

View File

@ -1,65 +1,65 @@
-- Refer: https://github.com/apache/flink/blob/master/flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserImplTest.java#L2016 -- Refer: https://github.com/apache/flink/blob/master/flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkSqlParserImplTest.java#L2016
-- Just for simple alter table statements, it not include alter table columns statements -- Just for simple alter table statements, it not include alter table columns statements
alter table ALTER TABLE
t1 rename to t2; t1 RENAME TO t2;
alter table ALTER TABLE
if exists t1 rename to t2; IF EXISTS t1 RENAME TO t2;
alter table ALTER TABLE
c1.d1.t1 rename to t2; c1.d1.t1 RENAME TO t2;
alter table ALTER TABLE
if exists c1.d1.t1 rename to t2; IF EXISTS c1.d1.t1 RENAME TO t2;
alter table ALTER TABLE
t1 rename a to b; t1 RENAME a TO b;
alter table ALTER TABLE
if exists t1 rename a to b; IF EXISTS t1 RENAME a TO b;
alter table ALTER TABLE
if exists t1 rename a.x to a.y; IF EXISTS t1 RENAME a.x TO a.y;
alter table ALTER TABLE
t1 t1
set set
('key1' = 'value1'); ('key1' = 'value1');
alter table ALTER TABLE
if exists t1 IF EXISTS t1
set set
('key1' = 'value1'); ('key1' = 'value1');
alter table ALTER TABLE
t1 t1
add ADD
constraint ct1 primary key(a, b); CONSTRAINT ct1 PRIMARY KEY(a, b);
alter table ALTER TABLE
t1 t1
add ADD
constraint ct1 primary key(a, b) not enforced; CONSTRAINT ct1 PRIMARY KEY(a, b) NOT ENFORCED;
alter table ALTER TABLE
if exists t1 IF EXISTS t1
add ADD
constraint ct1 primary key(a, b) not enforced; CONSTRAINT ct1 PRIMARY KEY(a, b) NOT ENFORCED;
alter table ALTER TABLE
t1 t1
add ADD
unique(a, b); UNIQUE(a, b);
alter table ALTER TABLE
if exists t1 IF EXISTS t1
add ADD
unique(a, b); UNIQUE(a, b);
alter table ALTER TABLE
t1 drop constraint ct1; t1 DROP CONSTRAINT ct1;
alter table ALTER TABLE
if exists t1 drop constraint ct1; IF EXISTS t1 DROP CONSTRAINT ct1;

View File

@ -25,4 +25,4 @@ CREATE TEMPORARY FUNCTION function1 AS 'org.apache.flink.function.function1' LAN
CREATE TEMPORARY SYSTEM FUNCTION function1 AS 'org.apache.flink.function.function1' LANGUAGE SCALA USING JAR '/path/to/test.jar'; CREATE TEMPORARY SYSTEM FUNCTION function1 AS 'org.apache.flink.function.function1' LANGUAGE SCALA USING JAR '/path/to/test.jar';
CREATE FUNCTION function1 AS 'org.apache.flink.function.function1' LANGUAGE JAVA USING JAR 'file:///path/to/test.jar', CREATE FUNCTION function1 AS 'org.apache.flink.function.function1' LANGUAGE JAVA USING JAR 'file:///path/to/test.jar',
jar 'hdfs:///path/to/test2.jar'; JAR 'hdfs:///path/to/test2.jar';

View File

@ -27,14 +27,14 @@ CREATE TABLE MyTable (
WATERMARK FOR order_time AS order_time - INTERVAL '5' SECOND WATERMARK FOR order_time AS order_time - INTERVAL '5' SECOND
) WITH ('connector' = 'kafka'); ) WITH ('connector' = 'kafka');
CREATE TABLE MyTable (id int, PRIMARY KEY (id) NOT ENFORCED) WITH ('connector' = 'kafka'); CREATE TABLE MyTable (id INT, PRIMARY KEY (id) NOT ENFORCED) WITH ('connector' = 'kafka');
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
a bigint, a BIGINT,
h varchar, h VARCHAR,
g AS 2 * (a + 1), g AS 2 * (a + 1),
ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'), ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'),
b varchar, b VARCHAR,
proc AS PROCTIME(), proc AS PROCTIME(),
meta STRING METADATA, meta STRING METADATA,
my_meta STRING METADATA FROM 'meta', my_meta STRING METADATA FROM 'meta',
@ -57,7 +57,7 @@ CREATE TABLE Orders_in_file (
); );
CREATE TABLE Orders_with_watermark ( CREATE TABLE Orders_with_watermark (
id int, id INT,
-- Add watermark definition -- Add watermark definition
WATERMARK FOR order_time AS order_time - INTERVAL '5' SECOND WATERMARK FOR order_time AS order_time - INTERVAL '5' SECOND
) WITH ( ) WITH (
@ -80,35 +80,35 @@ FROM
WHERE WHERE
mod(id, 10) = 0; mod(id, 10) = 0;
CREATE TABLE catalog1.db1.table1 (id int) WITH ('connector' = 'kafka'); CREATE TABLE catalog1.db1.table1 (id INT) WITH ('connector' = 'kafka');
CREATE TABLE catalog1.db1.table1 ( CREATE TABLE catalog1.db1.table1 (
attr0 STRING, attr0 STRING,
attr1 boolean, attr1 BOOLEAN,
attr3 decimal(38, 18), attr3 DECIMAL(38, 18),
attr4 TINYINT, attr4 TINYINT,
attr5 smallint, attr5 SMALLINT,
attr6 int, attr6 INT,
attr7 bigint, attr7 BIGINT,
attr8 float, attr8 FLOAT,
attr9 double, attr9 DOUBLE,
attr10 date, attr10 DATE,
attr11 time, attr11 TIME,
attr12 timestamp(3), attr12 TIMESTAMP(3),
attr13 array<STRING>, attr13 ARRAY<STRING>,
attr14 ROW<attr15 float, attr16 timestamp(3)>, attr14 ROW<attr15 FLOAT, attr16 TIMESTAMP(3)>,
attr17 MAP<int, bigint>, attr17 MAP<INT, BIGINT>,
name1 VARCHAR(64), name1 VARCHAR(64),
message ROW<data ROW<UPO_TIMESTAMP VARCHAR(20)>>, message ROW<data ROW<UPO_TIMESTAMP VARCHAR(20)>>,
raw RAW('class', 'snapshot') raw RAW('class', 'snapshot')
) WITH ('connector' = 'kafka'); ) WITH ('connector' = 'kafka');
CREATE TABLE IF NOT EXISTS tbl1 ( CREATE TABLE IF NOT EXISTS tbl1 (
a bigint, a BIGINT,
h varchar, h VARCHAR,
g AS 2 * (a + 1), g AS 2 * (a + 1),
ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'), ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'),
b varchar, b VARCHAR,
proc AS PROCTIME(), proc AS PROCTIME(),
PRIMARY KEY (a, b) NOT ENFORCED PRIMARY KEY (a, b) NOT ENFORCED
) PARTITIONED BY (a, h) WITH ( ) PARTITIONED BY (a, h) WITH (
@ -117,11 +117,11 @@ CREATE TABLE IF NOT EXISTS tbl1 (
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
a bigint COMMENT 'test column comment AAA.', a BIGINT COMMENT 'test column comment AAA.',
h varchar, h VARCHAR,
g AS 2 * (a + 1), g AS 2 * (a + 1),
ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'), ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'),
b varchar, b VARCHAR,
proc AS PROCTIME(), proc AS PROCTIME(),
meta STRING METADATA, meta STRING METADATA,
my_meta STRING METADATA FROM 'meta', my_meta STRING METADATA FROM 'meta',
@ -133,11 +133,11 @@ CREATE TABLE tbl1 (
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
a bigint COMMENT 'test column comment AAA.', a BIGINT COMMENT 'test column comment AAA.',
h varchar, h VARCHAR,
g AS 2 * (a + 1) COMMENT 'test computed column.', g AS 2 * (a + 1) COMMENT 'test computed column.',
ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'), ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'),
b varchar, b VARCHAR,
proc AS PROCTIME(), proc AS PROCTIME(),
PRIMARY KEY (a, b) NOT ENFORCED PRIMARY KEY (a, b) NOT ENFORCED
) COMMENT 'test table comment ABC.' PARTITIONED BY (a, h) WITH ( ) COMMENT 'test table comment ABC.' PARTITIONED BY (a, h) WITH (
@ -146,11 +146,11 @@ CREATE TABLE tbl1 (
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
a bigint, a BIGINT,
h varchar, h VARCHAR,
g AS 2 * (a + 1), g AS 2 * (a + 1),
ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'), ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'),
b varchar, b VARCHAR,
proc AS PROCTIME(), proc AS PROCTIME(),
PRIMARY KEY (a, b) NOT ENFORCED PRIMARY KEY (a, b) NOT ENFORCED
) WITH ( ) WITH (
@ -159,8 +159,8 @@ CREATE TABLE tbl1 (
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
a bigint PRIMARY KEY NOT ENFORCED COMMENT 'test column comment AAA.', a BIGINT PRIMARY KEY NOT ENFORCED COMMENT 'test column comment AAA.',
h varchar CONSTRAINT ct1 PRIMARY KEY NOT ENFORCED, h VARCHAR CONSTRAINT ct1 PRIMARY KEY NOT ENFORCED,
g AS 2 * (a + 1), g AS 2 * (a + 1),
ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'), ts AS toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'),
proc AS PROCTIME() proc AS PROCTIME()
@ -170,16 +170,16 @@ CREATE TABLE tbl1 (
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
ts timestamp(3), ts TIMESTAMP(3),
id varchar, id VARCHAR,
watermark FOR ts AS ts - INTERVAL '3' SECOND WATERMARK FOR ts AS ts - INTERVAL '3' SECOND
) WITH ( ) WITH (
'connector' = 'kafka', 'connector' = 'kafka',
'kafka.topic' = 'log.test' 'kafka.topic' = 'log.test'
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
log_ts varchar, log_ts VARCHAR,
ts AS to_timestamp(log_ts), ts AS to_timestamp(log_ts),
WATERMARK FOR ts AS ts + INTERVAL '1' SECOND WATERMARK FOR ts AS ts + INTERVAL '1' SECOND
) WITH ( ) WITH (
@ -188,7 +188,7 @@ CREATE TABLE tbl1 (
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
f1 ROW<q1 bigint, q2 ROW<t1 timestamp, t2 varchar>, q3 boolean>, f1 ROW<q1 BIGINT, q2 ROW<t1 TIMESTAMP, t2 VARCHAR>, q3 BOOLEAN>,
WATERMARK FOR f1.q2.t1 AS NOW() WATERMARK FOR f1.q2.t1 AS NOW()
) WITH ( ) WITH (
'connector' = 'kafka', 'connector' = 'kafka',
@ -196,36 +196,36 @@ CREATE TABLE tbl1 (
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
a ARRAY<bigint>, a ARRAY<BIGINT>,
b MAP<int, varchar>, b MAP<INT, VARCHAR>,
c ROW<cc0 int, cc1 float, cc2 varchar>, c ROW<cc0 INT, cc1 FLOAT, cc2 VARCHAR>,
d MULTISET<varchar>, d MULTISET<VARCHAR>,
PRIMARY KEY (a, b) NOT ENFORCED PRIMARY KEY (a, b) NOT ENFORCED
) with ( ) WITH (
'x' = 'y', 'x' = 'y',
'asd' = 'data' 'asd' = 'data'
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
a ARRAY<ARRAY<bigint>>, a ARRAY<ARRAY<BIGINT>>,
b MAP<MAP<int, varchar>, ARRAY<varchar>>, b MAP<MAP<INT, VARCHAR>, ARRAY<VARCHAR>>,
c ROW<cc0 ARRAY<int>, cc1 float, cc2 varchar>, c ROW<cc0 ARRAY<INT>, cc1 FLOAT, cc2 VARCHAR>,
d MULTISET<ARRAY<int>>, d MULTISET<ARRAY<INT>>,
f TIMESTAMP(9), f TIMESTAMP(9),
PRIMARY KEY (a, b) NOT ENFORCED PRIMARY KEY (a, b) NOT ENFORCED
) with ( ) WITH (
'x' = 'y', 'x' = 'y',
'asd' = 'data' 'asd' = 'data'
); );
CREATE TABLE tbl1 ( CREATE TABLE tbl1 (
a ARRAY<ARRAY<bigint>>, a ARRAY<ARRAY<BIGINT>>,
b MAP<MAP<int, varchar>, ARRAY<varchar>>, b MAP<MAP<INT, VARCHAR>, ARRAY<VARCHAR>>,
c ROW<cc0 ARRAY<int>, cc1 float, cc2 varchar>, c ROW<cc0 ARRAY<INT>, cc1 FLOAT, cc2 VARCHAR>,
d MULTISET<ARRAY<int>>, d MULTISET<ARRAY<INT>>,
f TIMESTAMP(9), f TIMESTAMP(9),
PRIMARY KEY (a, b) NOT ENFORCED PRIMARY KEY (a, b) NOT ENFORCED
) with ( ) WITH (
'x' = 'y', 'x' = 'y',
'asd' = 'data' 'asd' = 'data'
) LIKE Orders ( ) LIKE Orders (

View File

@ -1,43 +1,43 @@
INSERT INTO country_page_view INSERT INTO country_page_view
SELECT user, SELECT `user`,
cnt cnt
FROM page_view_source; FROM page_view_source;
INSERT INTO catalog1.db1.country_page_view INSERT INTO catalog1.db1.country_page_view
SELECT user, SELECT `user`,
cnt cnt
FROM page_view_source; FROM page_view_source;
--- Execute InsertStatement --- Execute InsertStatement
EXECUTE EXECUTE
INSERT INTO country_page_view PARTITION (date = '2019-8-30', country = 'China') INSERT INTO country_page_view PARTITION (`date` = '2019-8-30', country = 'China')
SELECT user, SELECT `user`,
cnt cnt
FROM page_view_source; FROM page_view_source;
--- Partition Clause: Static Partition --- Partition Clause: Static Partition
INSERT INTO country_page_view PARTITION (date = '2019-8-30', country = 'China') INSERT INTO country_page_view PARTITION (`date` = '2019-8-30', country = 'China')
SELECT user, SELECT `user`,
cnt cnt
FROM page_view_source; FROM page_view_source;
--- Partition Clause: Dynamic Partition --- Partition Clause: Dynamic Partition
INSERT INTO country_page_view PARTITION (date = '2019-8-30') INSERT INTO country_page_view PARTITION (`date` = '2019-8-30')
SELECT user, SELECT `user`,
cnt, cnt,
country country
FROM page_view_source; FROM page_view_source;
--- Column List Statement --- Column List Statement
INSERT INTO country_page_view PARTITION (date = '2019-8-30', country = 'China') (date, country) INSERT INTO country_page_view PARTITION (`date` = '2019-8-30', country = 'China') (`date`, country)
SELECT user, SELECT `user`,
cnt cnt
FROM page_view_source; FROM page_view_source;
--- Insert Method: OverWrite --- Insert Method: OverWrite
INSERT OVERWRITE country_page_view PARTITION (date = '2019-8-30') INSERT OVERWRITE country_page_view PARTITION (`date` = '2019-8-30')
SELECT user, SELECT `user`,
cnt, cnt,
country country
FROM page_view_source; FROM page_view_source;

View File

@ -8,7 +8,7 @@ VALUES ('Chinese', 'mumiao', 18),
('Amercian', 'georage', 22); ('Amercian', 'georage', 22);
EXECUTE EXECUTE
INSERT OverWrite country_page_view INSERT OVERWRITE country_page_view
VALUES ('Chinese', 'mumiao', 18), VALUES ('Chinese', 'mumiao', 18),
('Amercian', 'georage', 22); ('Amercian', 'georage', 22);

View File

@ -66,33 +66,33 @@ GROUP BY
-- Group Window Aggregation -- Group Window Aggregation
SELECT SELECT
user, `user`,
TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart, TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart,
SUM(amount) FROM Orders SUM(amount) FROM Orders
GROUP BY GROUP BY
TUMBLE(order_time, INTERVAL '1' DAY), TUMBLE(order_time, INTERVAL '1' DAY),
user; `user`;
SELECT SELECT
user, `user`,
TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart, TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart,
SUM(amount) FROM Orders SUM(amount) FROM Orders
GROUP BY GROUP BY
HOP(order_time, INTERVAL '1' DAY), HOP(order_time, INTERVAL '1' DAY),
user; `user`;
SELECT SELECT
user, `user`,
TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart, TUMBLE_START(order_time, INTERVAL '1' DAY) AS wStart,
SUM(amount) FROM Orders SUM(amount) FROM Orders
GROUP BY GROUP BY
SESSION(order_time, INTERVAL '1' DAY), SESSION(order_time, INTERVAL '1' DAY),
user; `user`;
-- Having -- Having
SELECT SUM(amount) SELECT SUM(amount)
FROM Orders FROM Orders
GROUP BY users GROUP BY `users`
HAVING SUM(amount) > 50; HAVING SUM(amount) > 50;
-- Over Aggregation -- Over Aggregation