forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Describe the bug
CREATE TABLE left_table_93ff3f0a_efdc_11f0_b8c7_de7b9eea3490
(
id Int32,
value Int32,
date_col Date,
computed ALIAS value * 2,
sum_alias ALIAS id + value
)
ENGINE = MergeTree()
ORDER BY (date_col, id)
PARTITION BY toYYYYMM(date_col);
CREATE TABLE right_table_93ff3f50_efdc_11f0_b8c7_de7b9eea3490
(
id Int32,
value Int32,
date_col Date,
computed ALIAS value * 2,
sum_alias ALIAS id + value
)
ENGINE = MergeTree()
ORDER BY (date_col, id)
PARTITION BY toYYYYMM(date_col);
INSERT INTO left_table_93ff3f0a_efdc_11f0_b8c7_de7b9eea3490 (id, value, date_col) VALUES
(1, 10, '2025-01-15'),
(2, 20, '2025-01-16'),
(3, 30, '2025-01-17');
INSERT INTO right_table_93ff3f50_efdc_11f0_b8c7_de7b9eea3490 (id, value, date_col) VALUES
(4, 40, '2025-01-10'),
(5, 50, '2025-01-11'),
(6, 60, '2025-01-12');
SET allow_experimental_hybrid_table = 1;
CREATE TABLE default.hybrid_table
(
`id` Int32,
`value` Int32,
`date_col` Date,
`computed` Int64,
`sum_alias` Int64
)
ENGINE = Hybrid(remote('localhost', currentDatabase(), left_table_93ff3f0a_efdc_11f0_b8c7_de7b9eea3490), computed >= 60, remote('localhost', currentDatabase(), right_table_93ff3f50_efdc_11f0_b8c7_de7b9eea3490), computed < '60');SELECT
id,
value,
computed,
sum_alias
FROM hybrid_table
Query id: a53a77d4-a89d-438d-a178-7547c5330dc8
Elapsed: 0.009 sec.
Received exception from server (version 25.8.12):
Code: 179. DB::Exception: Received from localhost:9000. DB::Exception: Multiple expressions __table1.value * 2 AS computed and __table1.computed for alias computed. In scope SELECT __table1.id AS id, __table1.value AS value, __table1.computed AS computed, __table1.sum_alias AS sum_alias FROM remote('localhost', 'default', 'right_table_93ff3f50_efdc_11f0_b8c7_de7b9eea3490') AS __table1 WHERE ((__table1.value * 2) AS computed) < '60'. (MULTIPLE_EXPRESSIONS_FOR_ALIAS)
select without alias column that was used in watermark returns wrong result but without exception:
SELECT
id,
value,
sum_alias
FROM hybrid_tableQuery id: 9721d894-3584-41a9-a23c-3cd0e7a8839a
┌─id─┬─value─┬─sum_alias─┐
1. │ 3 │ 30 │ 33 │
└────┴───────┴───────────┘
1 row in set. Elapsed: 0.010 sec.
Returned row where computed = 60.