Merge pull request #11495 from vzakaznikov/live_view_support_for_prewhere

Adding support for PREWHERE in live view tables.
This commit is contained in:
Nikolai Kochetov 2020-06-09 19:09:17 +03:00 committed by GitHub
commit 5cc2f318c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View File

@ -26,6 +26,11 @@ public:
return std::make_shared<StorageBlocks>(table_id, columns, std::move(pipes), to_stage);
}
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; }
Pipes read(

View File

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

View File

@ -0,0 +1,26 @@
SET allow_experimental_live_view = 1;
DROP TABLE IF EXISTS lv;
DROP TABLE IF EXISTS lv2;
DROP TABLE IF EXISTS mt;
CREATE TABLE mt (a Int32) Engine=MergeTree order by tuple();
CREATE LIVE VIEW lv AS SELECT sum(a) AS sum_a FROM mt PREWHERE a > 1;
CREATE LIVE VIEW lv2 AS SELECT sum(number) AS sum_number FROM system.numbers PREWHERE number > 1;
INSERT INTO mt VALUES (1),(2),(3);
SELECT *,_version FROM lv;
SELECT *,_version FROM lv PREWHERE sum_a > 5; -- { serverError 182 }
INSERT INTO mt VALUES (1),(2),(3);
SELECT *,_version FROM lv;
SELECT *,_version FROM lv PREWHERE sum_a > 10; -- { serverError 182 }
SELECT *,_version FROM lv2; -- { serverError 182 }
SELECT *,_version FROM lv2 PREWHERE sum_number > 10; -- { serverError 182 }
DROP TABLE lv;
DROP TABLE lv2;
DROP TABLE mt;