ClickHouse / ClickHouse

ClickHouse® is a real-time analytics DBMS
https://clickhouse.com
Apache License 2.0
37.19k stars 6.86k forks source link

Analyzer: issue with pushing down the condition from the view with FINAL to the distributed table #68030

Open filimonov opened 2 months ago

filimonov commented 2 months ago
CREATE TABLE test ENGINE=ReplacingMergeTree ORDER BY n AS SELECT intDiv(number,2) as n from numbers(10000000);

SET prefer_localhost_replica=0, max_bytes_to_read=1000000;
-- SET allow_experimental_analyzer=0;

SELECT '1st query';

SELECT * FROM cluster('default', currentDatabase(), test) FINAL WHERE n=100;

CREATE VIEW test_view AS SELECT * FROM cluster('default', currentDatabase(), test) FINAL;

SELECT '2nd query';

SELECT * from test_view WHERE n=100; --fails with analizer enabled

Fiddle: https://fiddle.clickhouse.com/5e00a72a-9989-4d57-93df-b5645b980b75

SaltTan commented 2 months ago

The same thing without FINAL https://fiddle.clickhouse.com/3c9bd2ba-f63f-4947-a906-1814781ff4a4

SaltTan commented 1 month ago

These look similar:

novikd commented 1 month ago

This likely can be fixed only by sending the query plan instead of AST to the followers.