Disabled implicit moving to PREWHERE when using FINAL [#METR-20644].

This commit is contained in:
Alexey Milovidov 2016-06-06 21:41:28 +03:00
parent 3e60a95cdd
commit 47898ae73b
6 changed files with 43 additions and 6 deletions

View File

@ -130,9 +130,8 @@ BlockInputStreams StorageMergeTree::read(
auto & select = typeid_cast<const ASTSelectQuery &>(*query); auto & select = typeid_cast<const ASTSelectQuery &>(*query);
/// Try transferring some condition from WHERE to PREWHERE if enabled and viable /// Try transferring some condition from WHERE to PREWHERE if enabled and viable
if (settings.optimize_move_to_prewhere) if (settings.optimize_move_to_prewhere && select.where_expression && !select.prewhere_expression && !select.final)
if (select.where_expression && !select.prewhere_expression) MergeTreeWhereOptimizer{query, context, data, column_names, log};
MergeTreeWhereOptimizer{query, context, data, column_names, log};
return reader.read(column_names, query, context, settings, processed_stage, max_block_size, threads, nullptr, 0); return reader.read(column_names, query, context, settings, processed_stage, max_block_size, threads, nullptr, 0);
} }

View File

@ -2089,9 +2089,8 @@ BlockInputStreams StorageReplicatedMergeTree::read(
auto & select = typeid_cast<const ASTSelectQuery &>(*query); auto & select = typeid_cast<const ASTSelectQuery &>(*query);
/// Try transferring some condition from WHERE to PREWHERE if enabled and viable /// Try transferring some condition from WHERE to PREWHERE if enabled and viable
if (settings.optimize_move_to_prewhere) if (settings.optimize_move_to_prewhere && select.where_expression && !select.prewhere_expression && !select.final)
if (select.where_expression && !select.prewhere_expression) MergeTreeWhereOptimizer{query, context, data, real_column_names, log};
MergeTreeWhereOptimizer{query, context, data, real_column_names, log};
Block virtual_columns_block; Block virtual_columns_block;
auto column = std::make_shared<ColumnUInt8>(2); auto column = std::make_shared<ColumnUInt8>(2);

View File

@ -0,0 +1,11 @@
1
0
1
4
9
16
25
36
49
64
81

View File

@ -0,0 +1,11 @@
DROP TABLE IF EXISTS test.v1;
DROP TABLE IF EXISTS test.v2;
CREATE VIEW test.v1 AS SELECT 1 FROM (SELECT 1);
SELECT * FROM test.v1;
CREATE VIEW test.v2 AS SELECT number * number FROM (SELECT number FROM system.numbers LIMIT 10);
SELECT * FROM test.v2;
DROP TABLE test.v1;
DROP TABLE test.v2;

View File

@ -0,0 +1,5 @@
2016-06-02 1 version 0 0
2016-06-02 1 version 1 1
2016-06-02 2 version 1 1
2016-06-02 1 version 1 1
2016-06-02 2 version 1 1

View File

@ -0,0 +1,12 @@
DROP TABLE IF EXISTS test.replace;
CREATE TABLE test.replace ( EventDate Date, Id UInt64, Data String, Version UInt32) ENGINE = ReplacingMergeTree(EventDate, Id, 8192, Version);
INSERT INTO test.replace VALUES ('2016-06-02', 1, 'version 1', 1);
INSERT INTO test.replace VALUES ('2016-06-02', 2, 'version 1', 1);
INSERT INTO test.replace VALUES ('2016-06-02', 1, 'version 0', 0);
SELECT * FROM test.replace ORDER BY Id, Version;
SELECT * FROM test.replace FINAL ORDER BY Id, Version;
SELECT * FROM test.replace FINAL WHERE Version = 0 ORDER BY Id, Version;
DROP TABLE test.replace;