Adding support for PREWHERE in live view tables.

This commit is contained in:
Vitaliy Zakaznikov 2020-06-08 00:19:23 +02:00
parent ecca78d855
commit 75c97ca82a
4 changed files with 30 additions and 0 deletions

View File

@ -26,6 +26,11 @@ public:
return std::make_shared<StorageBlocks>(table_id, columns, std::move(pipes), to_stage); return std::make_shared<StorageBlocks>(table_id, columns, std::move(pipes), to_stage);
} }
std::string getName() const override { return "Blocks"; } std::string getName() const override { return "Blocks"; }
/// It is passed inside the query and solved at its level.
bool supportsPrewhere() const override { return true; }
bool supportsSampling() const override { return true; }
bool supportsFinal() const override { return true; }
QueryProcessingStage::Enum getQueryProcessingStage(const Context &, QueryProcessingStage::Enum /*to_stage*/, const ASTPtr &) const override { return to_stage; } QueryProcessingStage::Enum getQueryProcessingStage(const Context &, QueryProcessingStage::Enum /*to_stage*/, const ASTPtr &) const override { return to_stage; }
Pipes read( Pipes read(

View File

@ -65,6 +65,7 @@ public:
ASTPtr getInnerBlocksQuery(); ASTPtr getInnerBlocksQuery();
/// It is passed inside the query and solved at its level. /// It is passed inside the query and solved at its level.
bool supportsPrewhere() const override { return true; }
bool supportsSampling() const override { return true; } bool supportsSampling() const override { return true; }
bool supportsFinal() const override { return true; } bool supportsFinal() const override { return true; }

View File

@ -0,0 +1,4 @@
5 1
5 1
10 2
10 2

View File

@ -0,0 +1,20 @@
SET allow_experimental_live_view = 1;
DROP TABLE IF EXISTS lv;
DROP TABLE IF EXISTS mt;
CREATE TABLE mt (a Int32) Engine=MergeTree order by tuple();
CREATE LIVE VIEW lv AS SELECT sum(a) FROM mt PREWHERE a > 1;
INSERT INTO mt VALUES (1),(2),(3);
SELECT *,_version FROM lv;
SELECT *,_version FROM lv;
INSERT INTO mt VALUES (1),(2),(3);
SELECT *,_version FROM lv;
SELECT *,_version FROM lv;
DROP TABLE lv;
DROP TABLE mt;