mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
86e9b131c7
It can be not that special to have Merge engine w/o default expression, while MergeTree will have it. So improve PREWHERE for such kinds, and also allow PREWHERE for DEFAULT and MATERIALIZED (since both are physical columns on disk and this make sense). Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
39 lines
817 B
SQL
39 lines
817 B
SQL
-- You cannot query EPHEMERAL
|
|
|
|
DROP TABLE IF EXISTS m;
|
|
DROP TABLE IF EXISTS t1;
|
|
DROP TABLE IF EXISTS t2;
|
|
|
|
CREATE TABLE m
|
|
(
|
|
`a` String,
|
|
`f` UInt8 EPHEMERAL 0
|
|
)
|
|
ENGINE = Merge(currentDatabase(), '^(t1|t2)$');
|
|
|
|
CREATE TABLE t1
|
|
(
|
|
a String,
|
|
f UInt8 DEFAULT 1
|
|
)
|
|
ENGINE = MergeTree
|
|
ORDER BY tuple()
|
|
SETTINGS index_granularity = 8192;
|
|
INSERT INTO t1 (a) VALUES ('OK');
|
|
|
|
CREATE TABLE t2
|
|
(
|
|
a String,
|
|
f UInt8 DEFAULT 2
|
|
)
|
|
ENGINE = MergeTree
|
|
ORDER BY tuple()
|
|
SETTINGS index_granularity = 8192;
|
|
INSERT INTO t2 (a) VALUES ('OK');
|
|
|
|
-- { echoOn }
|
|
SELECT * FROM m PREWHERE a = 'OK' ORDER BY a;
|
|
SELECT * FROM m PREWHERE f = 1 ORDER BY a; -- { serverError ILLEGAL_PREWHERE }
|
|
SELECT * FROM m WHERE a = 'OK' SETTINGS optimize_move_to_prewhere=0;
|
|
SELECT * FROM m WHERE a = 'OK' SETTINGS optimize_move_to_prewhere=1;
|