You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Select from Merge table (over MergeTree and Buffer) with two or more clauses in the Where throws exception #36963
Select from Merge table, which works with MergeTree table and Buffer table above MergeTree table, with two or more clauses in the Where, throws exception.
-- create tablescreatetablemt1 (f1 Int32, f2 Int32) engine = MergeTree() order by f1;
createtablemt2as mt1 engine = MergeTree() order by f1;
createtablebas mt1 engine = Buffer(currentDatabase(), mt2, 16, 1, 1, 10000, 1000000, 10000000, 100000000);
createtablemas mt1 engine = Merge(currentDatabase(), '^(mt1|b)$');
-- insert some datainsert into mt1 values(1, 1), (2, 2);
insert into b values(3, 3), (4, 4);
-- do selectselect f1, f2
from m
where f1 =1and f2 =1
Select throws exception:
Code: 44. DB::Exception: Cannot convert column `equals(f1, 1)` because it is non constant in source stream but must be constant in result. (ILLEGAL_COLUMN) (version 22.3.5.5 (official build))
The interesting part that no exceptions are thrown if the Where has only one clause:
select f1, f2
from m
where f1 =1-- f1|f2|-- --+--+-- 1| 1|select f1, f2
from m
where toUInt8(f1 =1and f2 =1)
-- f1|f2|-- --+--+-- 1| 1|
It's tested that type of column and function in the Where do not matter.
Expected behavior
Select completes without exceptions.
Error message and/or stacktrace
Code: 44. DB::Exception: Cannot convert column equals(f1, 1) because it is non constant in source stream but must be constant in result. (ILLEGAL_COLUMN)
To 100% reproduce this problem you should add sleep after adding data to buffer and before select. Data must be flushed to buffer target. I've added a sample in clickhouse-fiddle.
The usage of optimize_move_to_prewhere=0 solves problem but I think it may have some performance impact.
Activity
SaltTan commentedon May 6, 2022
Maybe related #36300?
alexey-milovidov commentedon Jul 2, 2022
Reproduced on version 22.7.
SergeyKotyushkin commentedon Feb 13, 2023
@KochetovNicolai, hello, do you have any updates on this issue?
In addition I figured out few things:
sleepafter adding data to buffer and before select. Data must be flushed to buffer target. I've added a sample in clickhouse-fiddle.optimize_move_to_prewhere=0solves problem but I think it may have some performance impact.The issue is still actual.
nikitamikhaylov commentedon Apr 9, 2024
Doesn't reproduce anymore https://fiddle.clickhouse.com/6baac43d-8119-4be0-9391-dfc78893bfe0
Will close the issue and add a test.
Close: #36963