Skip to content

Randomize the Parquet reader and writer settings in stateless tests - #132712

Merged
murphy-4o merged 4 commits into
ClickHouse:masterfrom
groeneai:randomize-parquet-reader-writer-settings
Nov 19, 2026
Merged

murphy-4o merged 4 commits into
ClickHouse:masterfrom
groeneai:randomize-parquet-reader-writer-settings

Conversation

@groeneai

@groeneai groeneai commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #132584

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Description

Only input_format_parquet_dictionary_filter_push_down was randomized, so every other Parquet reader and writer setting ran at its default in every CI run (Tests item of #132584; Reader.h TODO "make sure ~all reader and writer settings are randomized in tests").

This adds 25 settings to SettingsRandomizer, in one block after that entry:

  • reader: filter, bloom filter and page filter push-down, offset index, checksum verification, row group prefetch, preserve_order, local_file_min_bytes_for_seek, max_block_size, prefer_block_bytes, memory low and high watermarks;
  • writer: row group size in rows and bytes, data page size, batch size, page index, bloom filter (on/off, bits per value, flush threshold), compression method, parallel encoding, max dictionary size, checksums, ALP encoding.

Each one changes the file layout or the reader's code path, not the rows a query returns. Not randomized: settings that change a written or inferred type, and the three that #106734 adds; its runner patch still applies on top. Lower bounds keep the largest test writes at a few thousand row groups and reader blocks at 1000 rows or more.

What it uncovered: 49 tests pin settings with a Random settings limits: line. Most assert the mechanism a setting controls (rows read, pages, encodings, bloom filter sizes, cache entries, pipeline shape, file size, the codec); in ten, value checks kept passing while a random value removed the dictionary, bloom filter or page index their case needs. No value produced a wrong result or a crash. One interaction: with input_format_parquet_preserve_order = 1 and a 64 MiB input_format_parquet_memory_low_watermark, top-K dynamic filtering skips no row groups (same rows returned).

Validation on the 634 Parquet and data lake tests: 10 runs with random draws and 9 with forced extreme profiles, no new failure after the pins, total test time 1.03x; each pinned test 50x; each pin checked in system.query_log and by a negative control.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/132712]

Version info

  • Merged into: 26.11.1.2850-master (included in 26.11 and later)

Only `input_format_parquet_dictionary_filter_push_down` was randomized, so the
other reader and writer settings ran at their defaults in every CI run.
Add 25 more to `SettingsRandomizer`: the reader push-downs, offset index,
checksums, prefetch, `preserve_order`, block sizes, memory watermarks and the
seek threshold, and the writer row group / page / batch sizes, page index,
bloom filter, compression, dictionary, checksums and ALP. Every one of them
changes the file layout or the reader's code path, not the rows a query
returns. Settings that change a written or inferred type are not randomized;
the three that ClickHouse#106734 adds are left to it.

Lower bounds keep the largest writes of the test corpus at a few thousand row
groups and tens of thousands of pages, and reader blocks at >= 100 rows.

44 tests observe the mechanism a setting controls (rows read after pruning or
top-K filtering, pages per column, encodings, bloom filter sizes, columns cache
entries, memory limits, pipeline shape, file size, the codec a test is about)
and now clamp it with a `Random settings limits:` line. The culprit settings
were found by running the failing tests under each listed value forced alone,
and under leave-one-out subsets of the forced profiles for the combinations.

Related: ClickHouse#132584

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings), plus my own cold review of the same diff (3 nits).

# Sev Finding Verdict Evidence / action
1 💡 Local runs used a debug build only; release and sanitizer runtimes under the slow draws were not measured AGREE, noted The runtime check is relative (1.03x over 634 tests); this PR's own CI runs every stateless configuration
2 💡 Four Parquet and data lake tests landed on master after the base commit AGREE, noted Read each: they assert returned rows, Delta Lake file scans, or set their own reader settings; CI runs them on the merge commit

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-11:20261118-160301

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? N/A for the coverage change itself. Every failure the new randomization exposed reproduces by forcing one value (3/3) or one named pair of values (50/50) with the patched runner.
b Root cause explained? SettingsRandomizer.settings listed one Parquet setting, so the other reader and writer settings ran at their defaults in every CI run.
c Fix matches root cause? 25 settings added to the randomizer. A test that asserts the mechanism a setting controls pins only that setting with a Random settings limits: line; no blanket tag, no widened reference.
d Test intent preserved / new tests added? Each pin clamps only the measured setting; all other randomization stays on. Runner change, so no runner self-test; validated locally on the 634 Parquet and data lake tests.
e Both directions demonstrated? One negative control per pinned setting (22): the copy with the limits line disabled fails 3/3 or 5/5 under the breaking value, the pinned test passes.
f Fix is general across code paths? The test set covers every Parquet surface: file, url, s3, Iceberg, DeltaLake, Hudi, Paimon and INSERT ... FORMAT Parquet.
g Fix generalizes across inputs (params/datatypes/wrappers)? Every listed value of every setting was forced over the whole set; all 79 values are accepted over native and HTTP.
h Backward compatible? (maintainer-approved exception only) Yes: no setting, default or format change.
i Invariants and contracts preserved? No value changed returned rows in 19 full runs; lower bounds keep the largest writes small; total test time 1.03x of the base runner.

Session id: cron:clickhouse-impl-slot-40:20261118-150308

@clickhouse-gh

clickhouse-gh Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b5dcbd0]

Summary: ✅


AI Review

Summary

PR #132712 adds 25 randomized Parquet reader and writer settings and constrains 49 tests to preserve their intended regression coverage. Reviewed head: b5dcbd0c557736cbee939889e7dddf85cb737bf3. Both previous dictionary-coverage findings are addressed; no unresolved blockers or majors remain.

Missing context / blind spots
  • ⚠️ The full stateless and sanitizer CI results for this head are still pending. Fast test passed. No local server tests were rerun because this checkout has no available ClickHouse binary; completed CI will close that validation gap.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI comp-testing Test content only (no production code). labels Nov 18, 2026
clickhouse-gh[bot]
clickhouse-gh Bot previously approved these changes Nov 18, 2026
The flaky and targeted checks of the previous commit failed on two tests.

05401_parquet_object_storage_column_data_read_ahead exceeded the 32 MB
limit of its d_s3_limit_32mb query. The first row group of _big.parquet
has 1046544 rows, 46544 of them distinct. Their 372 KB dictionary is
abandoned when output_format_parquet_max_dictionary_size is below 1 MiB,
so the row group is 8.4 MB of PLAIN data instead of 465 KB. With that
layout and 100-row blocks the query peaks at 30-32 MiB under ASan and
fails 10 of 10 runs. The test's limits line now keeps the dictionary size
at 1 MiB or more, which gives the file the layout its comment describes.

05055_string_filters_during_scan_parquet and 05401 ran past the 180 s
limit of the flaky check with input_format_parquet_max_block_size = 100
or input_format_parquet_prefer_block_bytes = 1 (9 of 9 such failures).
With 16 copies of 05055 on 2 cores the median run takes 130-134 s with
those values, 70 s with the defaults and 81-86 s with blocks of 1000 rows
or 64 KiB, so these are now the lower bounds of the two settings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh
clickhouse-gh Bot dismissed their stale review November 18, 2026 20:54

AI review of a later commit does not approve the PR, see the AI Review comment.

…t tests live

Some regression cases of these tests only check a result that a full scan
returns as well, so a randomized setting that turns their mechanism off
makes them pass without testing anything.

05055_string_filters_during_scan_parquet: with
output_format_parquet_max_dictionary_size = 0 or 1 the dict, RLE and
one-value fixtures are written with PLAIN pages only, and with
input_format_parquet_memory_high_watermark = 1 or 1 MiB the pruning case
never materializes the dictionary. Both settings are bounded now. The test
also runs in the fast test, whose build has no ParquetMetadata format, so it
cannot check the encodings itself.

05230_parquet_int_signedness_no_minmax_pruning and
05331_parquet_bool_hint_nonzero_is_true: the same two settings for their
dictionary fixtures and dictionary filter cases.

05099_parquet_uuid_no_minmax_pruning: the page index case needs
input_format_parquet_page_filter_push_down and
output_format_parquet_write_page_index.

05241_parquet_hash_filter_output_type_value_space: part 1 needs the bloom
filter written and read when the dictionary filter is drawn as 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread tests/clickhouse-test Resolved
… live

These tests compare values only, so they kept passing when a random
setting removed the encoding or the index their case is about:

- 05406: a random `output_format_parquet_max_dictionary_size` of 0, 1
  or 1024 writes the dictionary round trip without a dictionary, and
  `output_format_parquet_use_alp_encoding = 1` writes float columns
  without one at any size, so the case that the dictionary keeps zero,
  negative zero and NaNs with different payloads apart tested nothing.
  Bound the dictionary size to at least 1 MiB and pin ALP off.
- 04646: the two cases of the exact dictionary filter need a
  dictionary page and the dictionary pruning pass, which a high
  watermark of 1 byte or 1 MiB skips. Bound both, as in 05055.
- 02735: 1M distinct values must grow the dictionary past its 1 MiB
  limit. With 0 no dictionary is tried, and with 1 or 1024 the writer
  drops it within the first two batches, so bound it to at least 1 MiB.
- 04097: the bloom filter prefetch regression needs a bloom filter
  written with the default bits per value and read with push-down.
- 04545: it also covers the page index path, which needs a page index.

The other Parquet tests either set these settings on their writes and
reads, assert the encodings, the bloom filters or the pruning, or do
not depend on them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@murphy-4o
murphy-4o added this pull request to the merge queue Nov 19, 2026
Merged via the queue into ClickHouse:master with commit b03acab Nov 19, 2026
192 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 19, 2026
murphy-4o added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
Re-run CI with the Parquet settings randomization (ClickHouse#132712).
murphy-4o added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
…ical-type-test

Re-run CI with the Parquet settings randomization (ClickHouse#132712).
murphy-4o added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
Re-run CI with the Parquet settings randomization (ClickHouse#132712).
murphy-4o added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
Re-run CI with the Parquet settings randomization (ClickHouse#132712).
murphy-4o added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
…rence

Re-run CI with the Parquet settings randomization (ClickHouse#132712).
murphy-4o added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
Re-run CI with the Parquet settings randomization (ClickHouse#132712).
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
The stateless test runner now randomizes the Parquet writer settings
(ClickHouse#132712), and 05512 counts offset index hits per column chunk of files
it writes, so the counts depend on the file layout:

- output_format_parquet_write_page_index = 0 writes no offset index, so
  nothing is kept or used (every hit count drops to 0).
- output_format_parquet_row_group_size_bytes below 512 MiB splits the
  100000-row files into several row groups (the counts double or
  more), and makes both versions of the rewritten file identical, so
  its first read is a hit instead of a miss.
- output_format_parquet_row_group_size below 1000000 splits the
  200000-row file whose offset index must be too large to keep into
  row groups whose offset indexes are kept.

Clamp the three to their defaults. Measured with master's runner: 19 of
30 runs failed before, 100 of 100 pass after; forcing each setting to
a bad value fails 10 of 10 runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
The stateless runner now randomizes `output_format_parquet_write_page_index`
(ClickHouse#132712). Without the page index the P case cannot skip pages, so
`ParquetRuntimeFilterPrunedPages` is 0 instead of 7 (25 flaky check runs, all with
the setting drawn `False`). The other randomized Parquet settings do not change
the counts: 100/100 runs with them randomized.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
Since ClickHouse#132712 randomizes the Parquet reader and writer settings, 05507 failed
the flaky check in the merge queue (78 of 186 runs on 2026-11-19). Each failing
arm traced to one setting that changes a fixture's layout or what the reader
reads, forced alone or in a pair on master + this PR:

- input_format_parquet_use_offset_index = 0 reads no offset index, so the
  oracle of m/n counts no separate offset index request (2 -> 0).
- output_format_parquet_data_page_size below a chunk splits it into pages; with
  reader blocks of 1000 or 8192 rows the first block's pages fit the read task
  and are read ahead, so the hand-back of s is not reached (0 -> 1). That read
  is within the bound: 970102 bytes with prefetch vs 971782 without.
- output_format_parquet_row_group_size_bytes = 65536 with max_block_size below
  25000 rows cuts good/ into several row groups with short chunks, which are
  not read ahead (a, l and the page cache control 1 -> 0).
- compression_method = 'none' with no dictionary makes the small/ files larger
  than remote_read_min_bytes_for_seek, so they are read ahead (j 0 -> 1).

The limits line clamps these five to their defaults. 160 of 160 randomized
runs of the test pass with it, 28 of 50 with the line disabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
ClickHouse#132712 randomizes the Parquet writer and reader settings in stateless
tests, and 05628 observes the file layout (which pages are located from
the headers) and the bytes read. Three randomized values change what it
measures:

- `output_format_parquet_max_dictionary_size` below 1 MiB drops the
  dictionary of the string column, so the 1 KiB-page fixture gets ~29 KiB
  plain pages, which are located (`lazy_1024 0 3` -> `3 3`).
- `output_format_parquet_batch_size = 8192` makes every page at least
  8192 values, so the 1 KiB-page fixtures get 64 KiB pages (the same
  diff, plus `bytes_1024 0 1` -> `1 1` and the bytes oracle `1` -> `0`).
- `input_format_parquet_local_file_min_bytes_for_seek = 1048576` reads
  through the gaps between the located pages, so the bytes oracle fails.

Clamp the three settings in the test's `Random settings limits` line, like
ClickHouse#132712 did for its own tests. `output_format_parquet_row_group_size_bytes`
is not clamped: the writer splits row groups by rows, and with the pinned
`max_block_size = 65409` the row groups are the same at every value.

Validated with the PR's own CI binary (amd_binary of 25f0833) and the
current runner: old test 36/60 FAIL under randomization, each adverse
value alone reproduces one CI diff shape; new test 50/50 sequential and
50/50 with -j10; the clamped values are what query_log shows; with the
clamp names corrupted 25/40 FAIL; master without this PR's source 3/3
FAIL with the original base lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
05836 failed 93 runs in 9 checks of both PR heads (flaky, targeted and
parallel). Master randomizes the Parquet writer settings in stateless
tests since ClickHouse#132712, and the test's assertions depend on where the
column chunks of its files fall relative to the 1 MiB segments of
`cache_for_readbigat`.

- `output_format_parquet_row_group_size_bytes` of 64 KiB or 1 MiB splits
  the files into many row groups, so reading `a` alone covers the `b` and
  `c` chunks between its chunks (rows 5 and 6 flip).
- `output_format_parquet_max_dictionary_size` below 1 MiB writes `a` and
  `c` PLAIN, and with pages of 1 KiB or less the extra page headers move
  the start of `c` of f2 past 3 MiB, into the last file segment. The cold
  footer read of row 5 touches that segment and background download
  completes it, so row 6 finds the whole file cached (row 6 flips).

Every failure on CIDB has one of these two shapes (78 and 15). A
`Random settings limits` line keeps both settings at their defaults,
which is the layout the comments describe.

With master's `tests/clickhouse-test`: 100 of 100 randomized runs pass
(-j 8); the same file with the limits line disabled fails 10 of 30;
query_log shows no INSERT below the limits with the line and values
down to 0 without it. With the limits, all 96 combinations of the
remaining writer settings (data page size, batch size, checksums, ALP,
parallel encoding) pass, and a master binary fails all 20 randomized
runs on exactly the three cached rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
The stateless runner randomizes the Parquet writer settings since ClickHouse#132712.

05838: with output_format_parquet_row_group_size_bytes = 65536 every block of
the INSERT becomes its own row group, and with max_block_size = 11538 each of
the top 5 rows is then alone in its row group. Its row-set entry holds one row
of a one-row range, so `top5 columns` (entries with fewer rows than their
range) is empty. With a byte limit of at least 512 MiB the rows are grouped by
output_format_parquet_row_group_size alone, and for every max_block_size the
runner draws (8000 to 100000) some row group has two of the top 5 rows. The
dictionary size limit keeps the constant column of `estimate const`
dictionary-encoded, so that the share of it the requested rows take stays
below one byte.

05832: output_format_parquet_data_page_size = 1 with a batch size of 100 makes
a page of every 100 rows, each compressed with brotli in the run that failed
Stateless tests (amd_asan_ubsan, flaky check): it read 167551 pages against
791 to 2852 in the other runs and took 234 s against 64 to 104 s. Keep the
default page size and compression.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
PedroTadim pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
The scheduler avoids deadlocks by always letting the first incomplete row group
schedule its tasks, whatever the memory usage. Since e7a7ac3 this exemption
applied only from `ColumnData` on. Before that, a later row group could get through
the bloom filter and `Dictionary` stages first and hold the `Dictionary` stage's
memory. The first incomplete row group then waited for that memory in `Dictionary`,
while the later row group waited in `ColumnData` to become first, and the reader threw
`Deadlock in Parquet::ReadManager`. This is reachable with a small
`input_format_parquet_memory_high_watermark`, which CI randomizes since ClickHouse#132712.

The stages before `ColumnData` handle the whole row group at once, so the first
incomplete row group is privileged in them unconditionally, as it was before
e7a7ac3.

The new test deadlocked in 4 of 10 runs without the fix, and passed 20 of 20
(with and without settings randomization) with it. In a `clickhouse-local` stress
run on a 298-row-group file: 100 deadlocks in 6000 runs before, 0 in 6000 after.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=133069&sha=a6c84af029f9bdc3526b34b1df2eae0b4b281294&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20plan-based%2C%20s3%20storage%2C%20parallel%29
PR: ClickHouse#133069
Closes: ClickHouse#133046

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 20, 2026
Since ClickHouse#131143 the reader checks the top-K threshold again when delivering a row
group, and counts a row group it stops there in `ParquetTopKSkippedRowGroups`
although its pages were read. So a read without the late check can now reach 38
skipped row groups, and "skipped plus read pages" is no longer 40 when such a
row group is counted (41-43 in 12 of 40 runs of the merged tree). The arms of
the late skip now wait for a read that reads 1 or 2 pages of the sort column:
without the late check every read reads at least 3 (230 of 230 reads, 12 of 12
test runs fail), with it 79% of the reads under 8 concurrent clients read 1 or 2.

Since ClickHouse#132712 the writer settings are randomized in stateless tests, and a data
page size of 1 or 1024 bytes splits the sort column of a row group into several
pages. The test pins `output_format_parquet_data_page_size` to at least 64 KiB,
one page per row group (measured for every other randomized writer setting).

The conflict in `ReadManager::clearRowSubgroup` is resolved by taking master's
version from ClickHouse#132621, which frees all the storage of the row subgroup and so
also the decoded leaves that the late skip can leave behind.
m7kss1 pushed a commit to m7kss1/ClickHouse that referenced this pull request Nov 20, 2026
…he randomized byte limit

ClickHouse#132712 randomizes output_format_parquet_row_group_size_bytes (64 KiB,
1 MiB, 16 MiB, 512 MiB). 05452 pins the row limit to write a single row
group, but not the byte limit. When the randomized max_block_size is below
10000, the 10000-row table reaches the Parquet writer in two chunks, and a
64 KiB or 1 MiB byte limit closes a row group at the chunk boundary
(ParquetBlockOutputFormat::consume checks it once per chunk). ParquetMetadata
reports the encodings of the last row group, whose 63-250-row tail fits
under the third section's 1000-byte dictionary limit, so the expected
['PLAIN'] becomes ['PLAIN','RLE_DICTIONARY'].

Clamp the byte limit to its default in the test's existing limits line, as
ClickHouse#132712 does in 05401, 05331 and 05482.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 21, 2026
The randomized Parquet writer settings (ClickHouse#132712) made the four 10M-row
fixtures of the test take up to 460 s in the tsan and msan flaky checks.
Write 1M rows and lower the memory limits from 40 MiB to 3 MiB. With
`max_block_size = 8192` and `max_untracked_memory = 0` a read in
`max_block_size` chunks peaks below 0.5 MiB, while one chunk of 1M UInt64
rows needs 7.63 MiB, so every case still fails when its exclusion is
removed.

Since ClickHouse#131185 an aggregation without GROUP BY copies at most 1 MiB of a
constant argument, so `count(x)` no longer materializes a one-chunk read.
The case counts `materialize(x)` instead, which still does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants