Skip to content

Commit 9a80830

Browse files
Avogarclaude
andcommitted
Make 04811_prewhere_subcolumn_size_setting robust to randomized settings
The test compared the on-disk sizes of constant (highly compressible) columns, so under the compression and granularity settings randomized by the flaky check the compressed sizes were tiny and could invert, flipping the PREWHERE condition ordering. Use incompressible random strings with a large size separation (exact(tup.small) < medium < size(tup)) so the ordering is stable regardless of the randomized compression, granularity and serialization settings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 97a939a commit 9a80830

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

tests/queries/0_stateless/04811_prewhere_subcolumn_size_setting.sql

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
-- `allow_calculating_subcolumns_sizes_for_merge_tree_reading` is enabled. When it is
33
-- disabled, the subcolumn is costed by its whole top-level column size instead.
44
--
5-
-- The table has a Tuple where the `small` element is tiny and the `big` element is huge,
6-
-- plus a `medium` column. With the setting on, `tup.small`'s exact size is smaller than
7-
-- `medium`, so it goes first in PREWHERE. With the setting off, `tup.small` is costed by
8-
-- the whole `tup` size (dominated by `big`), which is larger than `medium`, so `medium`
9-
-- goes first. Both conditions use equality so both are "good"; statistics are disabled so
10-
-- that only column sizes drive the ordering.
5+
-- The table has a Tuple where the `small` element is tiny and the `big` element is large,
6+
-- plus a `medium` column sized in between. With the setting on, `tup.small`'s exact size is
7+
-- smaller than `medium`, so it goes first in PREWHERE. With the setting off, `tup.small` is
8+
-- costed by the whole `tup` size (dominated by `big`), which is larger than `medium`, so
9+
-- `medium` goes first. Both conditions use equality so both are "good"; statistics are
10+
-- disabled so that only column sizes drive the ordering.
11+
--
12+
-- The data is incompressible random strings so that the size ordering
13+
-- exact(tup.small) < medium < size(tup) holds regardless of the compression and granularity
14+
-- settings randomized by the flaky check.
1115
--
1216
-- The analyzer path and the legacy InterpreterSelectQuery path are both covered; `tup.small`
1317
-- stays a subcolumn in both.
@@ -22,8 +26,8 @@ CREATE TABLE t_prewhere_subcolumn_size (id UInt64, medium String, tup Tuple(smal
2226
ENGINE = MergeTree ORDER BY id SETTINGS min_bytes_for_wide_part = 0;
2327

2428
INSERT INTO t_prewhere_subcolumn_size
25-
SELECT number, repeat('m', 50), (repeat('s', 1), repeat('b', 500))
26-
FROM numbers(200000);
29+
SELECT number, randomString(30), (randomString(1), randomString(300))
30+
FROM numbers(100000);
2731
OPTIMIZE TABLE t_prewhere_subcolumn_size FINAL;
2832

2933
SET enable_analyzer = 1;

0 commit comments

Comments
 (0)