2020-11-11 15:29:36 +00:00
|
|
|
DROP TABLE IF EXISTS ttl_repl1;
|
|
|
|
DROP TABLE IF EXISTS ttl_repl2;
|
2019-06-05 16:22:41 +00:00
|
|
|
|
2020-11-11 15:29:36 +00:00
|
|
|
CREATE TABLE ttl_repl1(d Date, x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/test_00933/ttl_repl', '1')
|
2019-06-05 16:22:41 +00:00
|
|
|
PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + INTERVAL 1 DAY;
|
2020-11-11 15:29:36 +00:00
|
|
|
CREATE TABLE ttl_repl2(d Date, x UInt32) ENGINE ReplicatedMergeTree('/clickhouse/tables/test_00933/ttl_repl', '2')
|
2019-06-05 16:22:41 +00:00
|
|
|
PARTITION BY toDayOfMonth(d) ORDER BY x TTL d + INTERVAL 1 DAY;
|
|
|
|
|
2020-11-11 15:29:36 +00:00
|
|
|
INSERT INTO TABLE ttl_repl1 VALUES (toDate('2000-10-10 00:00:00'), 100);
|
|
|
|
INSERT INTO TABLE ttl_repl1 VALUES (toDate('2100-10-10 00:00:00'), 200);
|
2019-06-05 16:22:41 +00:00
|
|
|
|
2020-11-11 15:29:36 +00:00
|
|
|
ALTER TABLE ttl_repl1 MODIFY TTL d + INTERVAL 1 DAY;
|
|
|
|
SYSTEM SYNC REPLICA ttl_repl2;
|
2019-06-05 16:22:41 +00:00
|
|
|
|
2020-11-11 15:29:36 +00:00
|
|
|
INSERT INTO TABLE ttl_repl1 VALUES (toDate('2000-10-10 00:00:00'), 300);
|
|
|
|
INSERT INTO TABLE ttl_repl1 VALUES (toDate('2100-10-10 00:00:00'), 400);
|
2019-06-05 16:22:41 +00:00
|
|
|
|
2020-11-11 15:29:36 +00:00
|
|
|
SYSTEM SYNC REPLICA ttl_repl2;
|
2019-06-05 16:22:41 +00:00
|
|
|
|
|
|
|
SELECT sleep(1) format Null; -- wait for probable merges after inserts
|
|
|
|
|
2020-11-11 15:29:36 +00:00
|
|
|
OPTIMIZE TABLE ttl_repl2 FINAL;
|
|
|
|
SELECT x FROM ttl_repl2 ORDER BY x;
|
2019-06-05 16:22:41 +00:00
|
|
|
|
2020-11-11 15:29:36 +00:00
|
|
|
SHOW CREATE TABLE ttl_repl2;
|
|
|
|
|
|
|
|
DROP TABLE ttl_repl1;
|
|
|
|
DROP TABLE ttl_repl2;
|