feat(flink): add inset\drop\alter grammar

This commit is contained in:
Erindcl
2020-10-28 16:15:41 +08:00
parent 6082c2b151
commit 158e235b01
10 changed files with 3977 additions and 2438 deletions

View File

@ -30,20 +30,16 @@ dmlStatement
: selectStatement | insertStatement
;
// Create statements
createTable
: CREATE TABLE tableName
: CREATE TABLE uid
LR_BRACKET
columnOptionDefinition (COMMA columnOptionDefinition)*
RR_BRACKET
partitionDefinition?
WITH LR_BRACKET
withOptionDefinition (COMMA withOptionDefinition)*
RR_BRACKET
;
tableName
: ID (DOT_ID)*?
withOption
;
columnOptionDefinition
@ -74,54 +70,118 @@ partitionColumnName
: ID
;
withOptionDefinition
: REVERSE_QUOTE_ID EQUAL_SYMBOL REVERSE_QUOTE_ID
;
createDatabase
:
: CREATE DATABASE ifNotExists? uid withOption
;
createView
:
: CREATE TEMPORARY? VIEW ifNotExists? uid AS selectStatement
;
createFunction
:
;
// Alter statements
alterTable
:
: ALTER TABLE uid (renameDefinition | setKeyValueDefinition)
;
renameDefinition
: RENAME TO uid
;
setKeyValueDefinition
: SET LR_BRACKET
keyValueDefinition (COMMA keyValueDefinition)*
RR_BRACKET
;
alterDatabase
:
: ALTER DATABASE uid setKeyValueDefinition
;
alterFunction
:
;
// Drop statements
dropTable
:
: DROP TABLE ifExists uid
;
dropDatabase
:
: DROP DATABASE ifExists uid dropType=(RESTRICT | CASCADE)?
;
dropView
:
: DROP TEMPORARY? VIEW ifExists uid
;
dropFunction
:
: DROP (TEMPORARY|TEMPORARY SYSTEM)? FUNCTION ifExists uid
;
// Select statements
selectStatement
:
;
// Insert statements
insertStatement
:
: INSERT (INTO | OVERWRITE) uid
(
insertPartitionDefinition? selectStatement
| valuesDefinition
)
;
insertPartitionDefinition
: PARTITION LR_BRACKET
keyValueDefinition (COMMA keyValueDefinition)*
RR_BRACKET
;
valuesDefinition
: VALUES valuesRowDefinition (COMMA valuesRowDefinition)*
;
// TODO 匹配所有的值 任意value
valuesRowDefinition
: LR_BRACKET
.*?
RR_BRACKET
;
// base common
uidList
: uid (',' uid)*
;
uid
: ID (DOT_ID)*?
;
withOption
: WITH LR_BRACKET
keyValueDefinition (COMMA keyValueDefinition)*
RR_BRACKET
;
ifNotExists
: IF NOT EXISTS;
ifExists
: IF EXISTS;
keyValueDefinition
: DOUBLE_QUOTE_ID EQUAL_SYMBOL DOUBLE_QUOTE_ID
;