mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Merge pull request #13618 from melin/master
antlr4 support complete create table grammar
This commit is contained in:
commit
291386fd2a
@ -27,9 +27,11 @@ K_CHECK : C H E C K;
|
||||
K_CLUSTER : C L U S T E R;
|
||||
K_COLUMN : C O L U M N;
|
||||
K_COLLATE : C O L L A T E;
|
||||
K_CODEC : C O D E C;
|
||||
K_CREATE : C R E A T E;
|
||||
K_CROSS : C R O S S;
|
||||
K_DAY : D A Y;
|
||||
K_DELETE : D E L E T E;
|
||||
K_DESCRIBE : D E S C R I B E;
|
||||
K_DESCENDING : D E S C E N D I N G;
|
||||
K_DESC : D E S C;
|
||||
@ -37,6 +39,7 @@ K_DATABASE : D A T A B A S E;
|
||||
K_DATABASES : D A T A B A S E S;
|
||||
K_DEFAULT : D E F A U L T;
|
||||
K_DETACH : D E T A C H;
|
||||
K_DISK : D I S K;
|
||||
K_DISTINCT : D I S T I N C T;
|
||||
K_DROP : D R O P;
|
||||
K_ELSE : E L S E;
|
||||
@ -104,8 +107,10 @@ K_TEST : T E S T;
|
||||
K_THEN : T H E N;
|
||||
K_TOTALS : T O T A L S;
|
||||
K_TO : T O;
|
||||
K_TTL : T T L;
|
||||
K_OUTER: O U T E R;
|
||||
K_VALUES : V A L U E S;
|
||||
K_VOLUME : V O L U M E;
|
||||
K_VIEW : V I E W;
|
||||
K_UNION : U N I O N;
|
||||
K_USE : U S E;
|
||||
|
@ -49,7 +49,7 @@ select_query_main
|
||||
select_groupby_step? select_having_step?
|
||||
select_orderby_step?
|
||||
select_limitby_step? select_limit_step?
|
||||
select_settings_step?
|
||||
settings_step?
|
||||
;
|
||||
|
||||
select_with_step
|
||||
@ -122,7 +122,7 @@ select_limitby_step
|
||||
: K_LIMIT NUMERIC_LITERAL K_BY not_empty_expression_list
|
||||
;
|
||||
|
||||
select_settings_step
|
||||
settings_step
|
||||
: K_SETTINGS assignment_list
|
||||
;
|
||||
|
||||
@ -143,7 +143,12 @@ create_query
|
||||
: ( K_CREATE | K_ATTACH ) K_TEMPORARY?
|
||||
( K_DATABASE ( K_IF K_NOT K_EXISTS ) ? database_name
|
||||
| K_TABLE ( K_IF K_NOT K_EXISTS ) ? full_table_name ( K_ON K_CLUSTER cluster_name ) ?
|
||||
( LPAREN column_declaration_list RPAREN engine ( K_AS select_query ) ? // если VIEW - то есть и колонки и select.
|
||||
( LPAREN column_declaration_list RPAREN engine ( K_AS select_query ) ?
|
||||
K_ORDER K_BY LPAREN order_by_expression_list RPAREN
|
||||
(K_PARTITION K_BY partitionExpr=expr)?
|
||||
(K_SAMPLE K_BY sampleExpr=expr)?
|
||||
table_ttl_list?
|
||||
settings_step?
|
||||
| engine K_AS ( select_query
|
||||
| full_table_name engine? // wtf
|
||||
)
|
||||
@ -315,6 +320,14 @@ order_by_element
|
||||
: expression_with_optional_alias ( K_DESC | K_DESCENDING | K_ASC | K_ASCENDING ) ? ( K_NULLS ( K_FIRST | K_LAST ) ) ? ( K_COLLATE STRING_LITERAL ) ?
|
||||
;
|
||||
|
||||
table_ttl_list
|
||||
: K_TTL table_ttl_declaration ( COMMA table_ttl_declaration ) *
|
||||
;
|
||||
|
||||
table_ttl_declaration
|
||||
: ttlExpr=expr (K_DELETE | K_TO K_DISK diskVal=STRING_LITERAL | K_TO K_VOLUME volumeVal=STRING_LITERAL)?
|
||||
;
|
||||
|
||||
nested_table
|
||||
: identifier LPAREN name_type_pair_list RPAREN
|
||||
;
|
||||
@ -336,10 +349,7 @@ column_declaration_list
|
||||
;
|
||||
|
||||
column_declaration
|
||||
: column_name
|
||||
( ( K_DEFAULT | K_MATERIALIZED | K_ALIAS ) expr
|
||||
| column_type
|
||||
)
|
||||
: column_name column_type (( K_DEFAULT | K_MATERIALIZED | K_ALIAS ) expr)? (K_CODEC(expr))? (K_TTL ttlExpr=expr)?
|
||||
;
|
||||
|
||||
column_name
|
||||
@ -581,4 +591,3 @@ err
|
||||
throw new RuntimeException("UNEXPECTED_CHAR=" + $UNEXPECTED_CHAR.text);
|
||||
}
|
||||
;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user