mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Add prewhere test
This commit is contained in:
parent
676b0fb2d6
commit
05a420ab20
@ -316,7 +316,8 @@ void MergeTreeRangeReader::ReadResult::optimize()
|
|||||||
/// Check if const 1 after shrink
|
/// Check if const 1 after shrink
|
||||||
if (countBytesInResultFilter(filter->getData()) + total_zero_rows_in_tails == total_rows_per_granule)
|
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();
|
setFilterConstTrue();
|
||||||
shrink(columns); /// shrink acts as filtering in such case
|
shrink(columns); /// shrink acts as filtering in such case
|
||||||
}
|
}
|
||||||
@ -326,7 +327,8 @@ void MergeTreeRangeReader::ReadResult::optimize()
|
|||||||
IColumn::Filter & new_data = new_filter->getData();
|
IColumn::Filter & new_data = new_filter->getData();
|
||||||
|
|
||||||
collapseZeroTails(filter->getData(), new_data);
|
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_original = filter;
|
||||||
filter_holder_original = std::move(filter_holder);
|
filter_holder_original = std::move(filter_holder);
|
||||||
filter = new_filter.get();
|
filter = new_filter.get();
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
43
|
||||||
|
1
|
14
dbms/tests/queries/0_stateless/01055_prewhere_bugs.sql
Normal file
14
dbms/tests/queries/0_stateless/01055_prewhere_bugs.sql
Normal 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;
|
Loading…
Reference in New Issue
Block a user