Skip to content

Commit 21e09b2

Browse files
Add regression test for UnionStep block structure mismatch with PREWHERE and projections
This test exercises the PREWHERE + projection + `query_plan_remove_unused_columns = 0` path that caused a debug assertion failure in `UnionStep::updatePipeline`. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent fadf657 commit 21e09b2

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://example.com/page1
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-- Regression test for Block structure mismatch in UnionStep with PREWHERE and projections.
2+
-- The debug assertion in UnionStep::updatePipeline fired before the header conversion code
3+
-- could fix the mismatch, causing an exception in debug/sanitizer builds.
4+
-- Triggered by PREWHERE optimization adding extra pass-through columns to ReadFromMergeTree
5+
-- output that are not consumed by the expression DAG above.
6+
-- https://github.com/ClickHouse/ClickHouse/issues/96131
7+
8+
SET enable_analyzer = 1;
9+
SET parallel_replicas_local_plan = 1;
10+
SET optimize_aggregation_in_order = 0;
11+
SET query_plan_remove_unused_columns = 0;
12+
SET min_table_rows_to_use_projection_index = 1000000;
13+
14+
DROP TABLE IF EXISTS test_union_prewhere_proj;
15+
CREATE TABLE test_union_prewhere_proj
16+
(
17+
id UInt64,
18+
event_date Date,
19+
user_id UInt32,
20+
url String,
21+
region String,
22+
PROJECTION region_url_proj
23+
(
24+
SELECT _part_offset ORDER BY region, url
25+
)
26+
)
27+
ENGINE = MergeTree
28+
ORDER BY (event_date, id)
29+
SETTINGS
30+
index_granularity = 1, min_bytes_for_wide_part = 0,
31+
min_bytes_for_full_part_storage = 0, enable_vertical_merge_algorithm = 0;
32+
33+
INSERT INTO test_union_prewhere_proj VALUES (1, '2023-01-01', 101, 'https://example.com/page1', 'europe');
34+
INSERT INTO test_union_prewhere_proj VALUES (2, '2023-01-01', 102, 'https://example.com/page2', 'us_west');
35+
36+
OPTIMIZE TABLE test_union_prewhere_proj FINAL;
37+
38+
SELECT url FROM test_union_prewhere_proj WHERE region = 'europe' ORDER BY ALL;
39+
40+
DROP TABLE test_union_prewhere_proj;

0 commit comments

Comments
 (0)