Merge pull request #41175 from ClickHouse/tautological_if_index

Add a test for #4242
This commit is contained in:
Alexey Milovidov 2022-09-10 18:07:04 +03:00 committed by GitHub
commit 3da8d2e9d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

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

View File

@ -0,0 +1,19 @@
DROP TABLE IF EXISTS constCondOptimization;
CREATE TABLE constCondOptimization
(
d Date DEFAULT today(),
time DateTime DEFAULT now(),
n Int64
)
ENGINE = MergeTree ORDER BY (time, n) SETTINGS index_granularity = 1;
INSERT INTO constCondOptimization (n) SELECT number FROM system.numbers LIMIT 10000;
-- The queries should use index.
SET max_rows_to_read = 2;
SELECT count() FROM constCondOptimization WHERE if(0, 1, n = 1000);
SELECT count() FROM constCondOptimization WHERE if(0, 1, n = 1000) AND 1 = 1;
DROP TABLE constCondOptimization;