Clickhouse:有没有办法在一个 `alter table drop partition ****` 查询中删除多分区?

Clickhouse: is there any way to drop multi-partition in one `alter table drop partition ****` query?

在 clickhouse 中,table 按天划分。现在,为了方便,我想在一个 alter 查询中删除多分区。

我是通过 shell 使用 while 循环完成的:

while [[ $startDate < $endDate ]]
do
    clickhouse-client --query="alter table db.table drop partition toYYYYMMDD(toDate($startDate))"
    startDate=`date -d "+1 day $startDate" +%Y-%m-%d`
done

我只是想找到一些可以轻松做到这一点的方法。有什么办法吗?谢谢~

您可以改为使用 ALTER TABLE <table> DELETE WHERE <partition-filters> 一次性删除多个分区。

你可以使用这个

ALTER TABLE my_table ON CLUSTER 'my-cluster'
    DROP PARTITION '2020-01-01',
    DROP PARTITION '2020-01-02',
    DROP PARTITION '2020-01-03'

很遗憾,好像还没有什么更方便的。