2020-03-30 12:58:00 +00:00
|
|
|
DROP TABLE IF EXISTS src_01019;
|
|
|
|
DROP TABLE IF EXISTS dest_01019;
|
|
|
|
DROP TABLE IF EXISTS pipe_01019;
|
2020-01-29 17:44:16 +00:00
|
|
|
|
2020-03-30 12:58:00 +00:00
|
|
|
CREATE TABLE src_01019(v UInt64) ENGINE = Null;
|
|
|
|
CREATE TABLE dest_01019(v UInt64) Engine = MergeTree() ORDER BY v;
|
2020-01-29 17:44:16 +00:00
|
|
|
|
2020-03-30 12:58:00 +00:00
|
|
|
CREATE MATERIALIZED VIEW pipe_01019 TO dest_01019 AS
|
|
|
|
SELECT v FROM src_01019;
|
2020-01-29 17:44:16 +00:00
|
|
|
|
2020-03-30 12:58:00 +00:00
|
|
|
INSERT INTO src_01019 VALUES (1), (2), (3);
|
2020-01-29 17:44:16 +00:00
|
|
|
|
|
|
|
SET allow_experimental_alter_materialized_view_structure = 1;
|
|
|
|
|
|
|
|
-- Live alter which changes query logic and adds an extra column.
|
2020-03-30 12:58:00 +00:00
|
|
|
ALTER TABLE pipe_01019
|
2020-01-29 17:44:16 +00:00
|
|
|
MODIFY QUERY
|
|
|
|
SELECT
|
|
|
|
v * 2 as v,
|
|
|
|
1 as v2
|
2020-03-30 12:58:00 +00:00
|
|
|
FROM src_01019;
|
2020-01-29 17:44:16 +00:00
|
|
|
|
2020-03-30 12:58:00 +00:00
|
|
|
INSERT INTO src_01019 VALUES (1), (2), (3);
|
2020-01-29 17:44:16 +00:00
|
|
|
|
2020-03-30 12:58:00 +00:00
|
|
|
SELECT * FROM dest_01019 ORDER BY v;
|
2020-01-29 17:44:16 +00:00
|
|
|
|
2020-03-30 12:58:00 +00:00
|
|
|
ALTER TABLE dest_01019
|
2020-01-29 17:44:16 +00:00
|
|
|
ADD COLUMN v2 UInt64;
|
|
|
|
|
2020-03-30 12:58:00 +00:00
|
|
|
INSERT INTO src_01019 VALUES (42);
|
|
|
|
SELECT * FROM dest_01019 ORDER BY v;
|
2020-01-29 17:44:16 +00:00
|
|
|
|
2020-03-30 12:58:00 +00:00
|
|
|
DROP TABLE src_01019;
|
|
|
|
DROP TABLE dest_01019;
|
|
|
|
DROP TABLE pipe_01019;
|