2018-08-07 17:08:51 +00:00
|
|
|
DROP TABLE IF EXISTS test.partitions;
|
2022-06-23 08:37:52 +00:00
|
|
|
set allow_deprecated_syntax_for_merge_tree=1;
|
2018-08-07 17:08:51 +00:00
|
|
|
CREATE TABLE test.partitions (EventDate Date, CounterID UInt32) ENGINE = MergeTree(EventDate, CounterID, 8192);
|
2018-12-29 22:11:00 +00:00
|
|
|
INSERT INTO test.partitions SELECT EventDate + UserID % 365 AS EventDate, CounterID FROM test.hits WHERE CounterID = 1704509;
|
2018-08-07 17:08:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
SELECT count() FROM test.partitions WHERE EventDate >= toDate('2015-01-01') AND EventDate < toDate('2015-02-01');
|
|
|
|
SELECT count() FROM test.partitions WHERE EventDate < toDate('2015-01-01') OR EventDate >= toDate('2015-02-01');
|
|
|
|
|
|
|
|
ALTER TABLE test.partitions DETACH PARTITION 201501;
|
|
|
|
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
SELECT count() FROM test.partitions WHERE EventDate >= toDate('2015-01-01') AND EventDate < toDate('2015-02-01');
|
|
|
|
SELECT count() FROM test.partitions WHERE EventDate < toDate('2015-01-01') OR EventDate >= toDate('2015-02-01');
|
|
|
|
|
|
|
|
ALTER TABLE test.partitions ATTACH PARTITION 201501;
|
|
|
|
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
SELECT count() FROM test.partitions WHERE EventDate >= toDate('2015-01-01') AND EventDate < toDate('2015-02-01');
|
|
|
|
SELECT count() FROM test.partitions WHERE EventDate < toDate('2015-01-01') OR EventDate >= toDate('2015-02-01');
|
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE test.partitions DETACH PARTITION 201403;
|
|
|
|
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
|
2018-12-29 22:11:00 +00:00
|
|
|
INSERT INTO test.partitions SELECT EventDate + UserID % 365 AS EventDate, CounterID FROM test.hits WHERE CounterID = 1704509 AND toStartOfMonth(EventDate) = toDate('2014-03-01');
|
2018-08-07 17:08:51 +00:00
|
|
|
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
|
|
|
|
ALTER TABLE test.partitions ATTACH PARTITION 201403;
|
|
|
|
|
|
|
|
SELECT count() FROM test.partitions;
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE test.partitions;
|