Add prewhere test

This commit is contained in:
Amos Bird 2019-12-31 16:09:37 +08:00
parent 676b0fb2d6
commit 05a420ab20
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 20 additions and 2 deletions

View File

@ -316,7 +316,8 @@ void MergeTreeRangeReader::ReadResult::optimize()
/// Check if const 1 after shrink
if (countBytesInResultFilter(filter->getData()) + total_zero_rows_in_tails == total_rows_per_granule)
{
num_rows = total_rows_per_granule = total_rows_per_granule - total_zero_rows_in_tails;
total_rows_per_granule = total_rows_per_granule - total_zero_rows_in_tails;
num_rows = total_rows_per_granule;
setFilterConstTrue();
shrink(columns); /// shrink acts as filtering in such case
}
@ -326,7 +327,8 @@ void MergeTreeRangeReader::ReadResult::optimize()
IColumn::Filter & new_data = new_filter->getData();
collapseZeroTails(filter->getData(), new_data);
num_rows = total_rows_per_granule = new_filter->size();
total_rows_per_granule = new_filter->size();
num_rows = total_rows_per_granule;
filter_original = filter;
filter_holder_original = std::move(filter_holder);
filter = new_filter.get();

View File

@ -0,0 +1,2 @@
43
1

View File

@ -0,0 +1,14 @@
DROP TABLE IF EXISTS test_prewhere_default_column;
DROP TABLE IF EXISTS test_prewhere_column_type;
CREATE TABLE test_prewhere_default_column (APIKey UInt8, SessionType UInt8) ENGINE = MergeTree() PARTITION BY APIKey ORDER BY tuple();
INSERT INTO test_prewhere_default_column VALUES( 42, 42 );
ALTER TABLE test_prewhere_default_column ADD COLUMN OperatingSystem UInt64 DEFAULT SessionType+1;
SELECT OperatingSystem FROM test_prewhere_default_column PREWHERE SessionType = 42;
CREATE TABLE test_prewhere_column_type (`a` LowCardinality(String), `x` Nullable(Int32)) ENGINE = MergeTree ORDER BY tuple();
INSERT INTO test_prewhere_column_type VALUES ('', 2);
SELECT a, y FROM test_prewhere_column_type prewhere (x = 2) AS y;