Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # создаем таблицу заранее
- CREATE TABLE kostya_test.view_result_table
- date Date,
- customer_id UInt32,
- val AggregateFunction (sum, UInt32))
- ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/kostya_test.view_table',
- '{replica}', date, (date, prom_customer_id, val), 8192);
- CREATE MATERIALIZED VIEW kostya_test.view_table
- TO kostya_test.view_result_table
- AS SELECT date, customer_id, sumState(val) AS val
- FROM test_db.log_41949_pageviews_product GROUP BY date, customer_id;
- # создаем таблицу неявно
- CREATE MATERIALIZED VIEW kostya_test.view_table
- ( date Date,
- customer_id UInt32,
- val AggregateFunction (sum, UInt32))
- ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/kostya_test.view_table',
- '{replica}', date, (date, prom_customer_id, val), 8192)
- AS SELECT date, customer_id, sumState(val) AS val
- FROM test_db.log_41949_pageviews_product GROUP BY date, customer_id;
- ## добавляем поле NEWCOL
- detach table kostya_test.view_table;
- alter table kostya_test.`.inner.view_table` add column NEWCOL String;
- ATTACH MATERIALIZED VIEW kostya_test.view_table
- ( date Date,
- customer_id UInt32,
- val AggregateFunction (sum, UInt32),
- NEWCOL String)
- ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/kostya_test.view_table',
- '{replica}', date, (date, prom_customer_id, val), 8192)
- AS SELECT date, customer_id, sumState(val) AS val,NEWCOL
- FROM test_db.log_41949_pageviews_product GROUP BY date, customer_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement