custom partition: is it possible to drop partition by hour

706 views
Skip to first unread message

tdingus

unread,
Nov 27, 2017, 1:04:50 PM11/27/17
to ClickHouse
Hi,

Now custom partition is available from version 54310, and one can drop a partition by day, for example,
ALTER TABLE ontime DROP PARTITION '1987-10-01';

Is it possible to drop custom partition by hour?

If the answer is yes, what is the command syntax?

Thanks

Vitaliy Lyudvichenko

unread,
Nov 28, 2017, 8:52:55 AM11/28/17
to ClickHouse
Yes, it is possible you could see a by-week example here https://github.com/yandex/ClickHouse/blob/b6b5d1cf25a82940346d8e105388e1ee0cc8fd78/dbms/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql#L49

If you use complex partition keys (random strings for example), you could specify PARTITION ID (which is its partition name hash) of the partition instead of full partition name: https://github.com/yandex/ClickHouse/blob/b6b5d1cf25a82940346d8e105388e1ee0cc8fd78/dbms/tests/queries/0_stateless/00502_custom_partitioning_replicated_zookeeper.sql#L49

What is your exact partition key?
You just could see partition id of the parts in system.parts table.

понедельник, 27 ноября 2017 г., 21:04:50 UTC+3 пользователь tdingus написал:

tdingus

unread,
Nov 28, 2017, 1:43:14 PM11/28/17
to ClickHouse
> What is your exact partition key?

Just like in the example, toDate(time) where time is UInt32.

I would suppose that I could do toHour(time) in this case. I will try that out.

Are there other alternatives?

Thanks for your help.
Reply all
Reply to author
Forward
0 new messages