Skip to content

Add test: PREWHERE producer of the query condition cache key untested for settings salt - #120128

Closed
clickgapai wants to merge 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr117803
Closed

clickgapai wants to merge 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr117803

Conversation

@clickgapai

@clickgapai clickgapai commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Test-only PR. Review: are the gaps real, is the test right.

Adds test coverage for 1 untested code path, found during automated review of PR #117803.
That PR: Folds a salt over ~90 settings that a function latches at build time (the formatdatetime_* / parsedatetime_* family, locate, least/greatest, the conversion and JSON format settings, the parser limits, short_circuit_function_evaluation, session_timezone, ...) into every query …

1. PREWHERE producer of the query condition cache key untested for settings salt
src/Storages/MergeTree/MergeTreeSelectProcessor.cpp:442, src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp:1704
Risk: MergeTreeSelectProcessor.cpp:442 is the only MergeTree key producer none of the PR's tests reach: the PR's SQL test uses SELECT count() exclusively, which keeps a FilterStep (EXPLAIN: 1 Filter (( line, 0 Prewhere filter column lines) so only the WHERE plan tag writes, and the PR's …
Unique vs PR tests: The PR's 05099_*.sql runs SELECT count() only — EXPLAIN shows a Filter step and no PREWHERE, so it exercises the WHERE plan tag and FilterTransform; its 05099_*_parquet.sh exercises FormatFilterInfo on the File engine. This test is the only one that drives the MergeTree PREWHERE …
Tags: -- Tags: no-parallel — no-parallel: drops the instance-wide query condition cache and asserts its entry count, which a parallel sibling test would perturb

cc @alexey-milovidov (author of #117803), @yariks5s (merged/approved #117803) — could you take a look, and add the can be tested label if this looks good?

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

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

@clickgapai

Copy link
Copy Markdown
Contributor Author
Pre-PR validation: 6/6 ✅

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Storages/MergeTree/MergeTreeSelectProcessor.cpp:442 — the PREWHERE write key queryConditionCacheHash(output->getHash(), reader_settings.query_condition_cache_settings_salt); no test in either tree drives this producer with two different values of any setting in the salt.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 05218_query_condition_cache_prewhere_formatdatetime_settings.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Sep 15, 2026
@zlareb1 zlareb1 added the can be tested Allows running workflows for external contributors label Sep 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9d285cf]

Summary: ✅


AI Review

Summary

This PR adds a focused stateless regression test for the MergeTree PREWHERE query-condition-cache path that was missing coverage in PR #117803. The current revision closes the only real gap from the earlier discussion by asserting read-side reuse from system.query_log (QueryConditionCacheHits / skipped marks), so the test now distinguishes a genuine warm-cache hit from a miss that merely rewrites the same key. I found no remaining correctness or robustness issues in the diff, and the current Praktika run for commit 9d285cf8 is green.

Final Verdict

✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 15, 2026
`count() FROM system.query_condition_cache` cannot tell a hit from a miss that
rewrites the same key. Tag the cold/warm/flipped queries with `log_comment` and
assert `QueryConditionCacheHits` and `SelectedMarks` < `SelectedMarksTotal`.

Requested by @clickhouse-gh[bot] in ClickHouse#120128 (comment)
@rschu1ze

Copy link
Copy Markdown
Member

@clickgapai I'm closing this PR. Instead, wait till #120690 is merged. Then suggest a minimal and elegant extension of the test case.

@rschu1ze rschu1ze closed this Sep 17, 2026
@clickhouse-gh clickhouse-gh Bot added comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. 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-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants