Atomic движком? С движком Ordinary это работает, а с Atomic -- нет. Версия ClickHouse — 21.12.3.32.
:) create database test_atomic ENGINE = Atomic;
0 rows in set. Elapsed: 0.003 sec.
:) use test_atomic;
USE test_atomic
0 rows in set. Elapsed: 0.001 sec.
:) CREATE TABLE test (date Date, hour Int8, x Int32) Engine = MergeTree ORDER BY tuple();
Ok.
0 rows in set. Elapsed: 0.005 sec.
:) CREATE MATERIALIZED VIEW mv (date Date, x Int32) ENGINE = SummingMergeTree() ORDER BY tuple() AS SELECT date, sum(x) AS x FROM test GROUP BY date;
Ok.
0 rows in set. Elapsed: 0.009 sec.
:) DETACH VIEW mv;
DETACH VIEW mv
Ok.
0 rows in set. Elapsed: 0.001 sec.
:) show tables
SHOW TABLES
┌─name───────────────────────────────────────────┐
│ .inner_id.21030636-49a4-462c-a103-063649a4262c │
│ test │
└────────────────────────────────────────────────┘
2 rows in set. Elapsed: 0.002 sec.
:) ALTER TABLE ".inner_id.21030636-49a4-462c-a103-063649a4262c" ADD COLUMN y Int32;
Ok.
0 rows in set. Elapsed: 0.004 sec.
:) ATTACH MATERIALIZED VIEW mv (date Date, x Int32, y Int32) ENGINE = SummingMergeTree() ORDER BY tuple() AS SELECT date, sum(x) AS x, 1 AS y FROM test GROUP BY date;
0 rows in set. Elapsed: 0.001 sec.
Received exception from server (version 21.12.3):
Code: 80. DB::Exception: Received from localhost:9000. DB::Exception: Incorrect ATTACH TABLE query for Atomic database engine. Use one of the following queries instead:
1. ATTACH TABLE mv;
2. CREATE TABLE mv <table definition>;
3. ATTACH TABLE mv FROM '/path/to/data/' <table definition>;
4. ATTACH TABLE mv UUID '<uuid>' <table definition>;. (INCORRECT_QUERY)
лучше всего делать MV вместе с TO dst_table потом DETACH MATERIALIZED VIEW + ALTER TABLE dst_table ADD COLUMN и потом делать CREATE OR REPLACE MATERIALIZED VIEW
Обсуждают сегодня