Test for bug with missing column in PREWHERE step

This commit is contained in:
Alexander Gololobov 2023-02-19 11:56:14 +01:00
parent f91a127175
commit 1d28da3263
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,30 @@
1 Hello, world! 0
2 Goodbye. 3
-- { echoOn }
SELECT s FROM test_02559 PREWHERE x AND y ORDER BY s;
Goodbye.
SELECT s, y FROM test_02559 PREWHERE y ORDER BY s;
Goodbye. 3
SELECT s, y FROM test_02559 PREWHERE NOT y ORDER BY s;
Hello, world! 0
SELECT s, y FROM test_02559 PREWHERE x AND y ORDER BY s;
Goodbye. 3
SELECT s, y FROM test_02559 PREWHERE x AND NOT y ORDER BY s;
Hello, world! 0
SELECT s, y FROM test_02559 PREWHERE y AND x ORDER BY s;
Goodbye. 3
SELECT s, y FROM test_02559 PREWHERE (NOT y) AND x ORDER BY s;
Hello, world! 0
ALTER TABLE test_02559 ADD COLUMN z UInt8 DEFAULT 10;
INSERT INTO test_02559 VALUES (3, 'So long, and thanks for all the fish.', 42, 0);
SELECT * FROM test_02559 ORDER BY x;
1 Hello, world! 0 10
2 Goodbye. 3 10
3 So long, and thanks for all the fish. 42 0
SELECT s FROM test_02559 PREWHERE z ORDER BY s;
Goodbye.
Hello, world!
SELECT s FROM test_02559 PREWHERE y AND z ORDER BY s;
Goodbye.
SELECT s, z FROM test_02559 PREWHERE NOT y AND z ORDER BY s;
Hello, world! 10

View File

@ -0,0 +1,30 @@
DROP TABLE IF EXISTS test_02559;
CREATE TABLE test_02559 (x UInt8, s String) ENGINE = MergeTree ORDER BY tuple();
INSERT INTO test_02559 VALUES (1, 'Hello, world!');
ALTER TABLE test_02559 ADD COLUMN y UInt8 DEFAULT 0;
INSERT INTO test_02559 VALUES (2, 'Goodbye.', 3);
SELECT * FROM test_02559 ORDER BY x;
SET enable_multiple_prewhere_read_steps=true, move_all_conditions_to_prewhere=true;
-- { echoOn }
SELECT s FROM test_02559 PREWHERE x AND y ORDER BY s;
SELECT s, y FROM test_02559 PREWHERE y ORDER BY s;
SELECT s, y FROM test_02559 PREWHERE NOT y ORDER BY s;
SELECT s, y FROM test_02559 PREWHERE x AND y ORDER BY s;
SELECT s, y FROM test_02559 PREWHERE x AND NOT y ORDER BY s;
SELECT s, y FROM test_02559 PREWHERE y AND x ORDER BY s;
SELECT s, y FROM test_02559 PREWHERE (NOT y) AND x ORDER BY s;
ALTER TABLE test_02559 ADD COLUMN z UInt8 DEFAULT 10;
INSERT INTO test_02559 VALUES (3, 'So long, and thanks for all the fish.', 42, 0);
SELECT * FROM test_02559 ORDER BY x;
SELECT s FROM test_02559 PREWHERE z ORDER BY s;
SELECT s FROM test_02559 PREWHERE y AND z ORDER BY s;
SELECT s, z FROM test_02559 PREWHERE NOT y AND z ORDER BY s;
-- { echoOff }
DROP TABLE test_02559;