alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
28k stars 8.59k forks source link

SQL Parser能否支持下clickhouse的DDL语法? #4318

Open yx91490 opened 3 years ago

yx91490 commented 3 years ago

如题

wenshao commented 3 years ago

支持的,遇到什么不支持的语法了?

yx91490 commented 3 years ago

支持的,遇到什么不支持的语法了?

比如如下的建表语句在clickhouse上执行会由于没有指定主键会报错:

CREATE TABLE db1.tab2
(
    `id` Int32
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/db1.tab2', '{replica}');

报错信息如下:

Received exception from server (version 20.8.7):
Code: 42. DB::Exception: Received from localhost:9000. DB::Exception: Storage ReplicatedMergeTree requires 5 to 6 parameters: 
path in ZooKeeper,
replica name,
name of column with date,
[sampling element of primary key],
primary key expression,
index granularity

Syntax for the MergeTree table engine:

CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
(
    name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1],
    name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2],
    ...
    INDEX index_name1 expr1 TYPE type1(...) GRANULARITY value1,
    INDEX index_name2 expr2 TYPE type2(...) GRANULARITY value2
) ENGINE = MergeTree()
ORDER BY expr
[PARTITION BY expr]
[PRIMARY KEY expr]
[SAMPLE BY expr]
[TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...]
[SETTINGS name=value, ...]

See details in documentation: https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/mergetree/. Other engines of the family support different syntax, see details in the corresponding documentation topics.

If you use the Replicated version of engines, see https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/replication/.
. 

使用1.2.6版本能正常解析出statement却没有报错产生。

yx91490 commented 3 years ago

补充下:其中on cluster xxx 不支持, primary key xxx 不支持,partition by 不支持,TTL语法不支持。

gj-zhang commented 3 years ago

+1

QinHao123-ai commented 3 years ago

+1

shmily1227 commented 11 months ago

+1

Kiss736921 commented 10 months ago

支持的,遇到什么不支持的语法了?

on cluster xxx 不支持, primary key xxx 不支持,partition by 不支持,TTL语法不支持,这几种语法有计划支持吗