Repository navigation
Add a test pinning the deferred-PREWHERE sync from #109703 - #112507
PedroTadim merged 1 commit into
Conversation
PR ClickHouse#109703 added a sync in ReadFromMergeTree::updatePrewhereInfo that copies a later PREWHERE rewrite into deferred_prewhere_info when the PREWHERE is deferred after FINAL. Neither test it shipped makes that line load-bearing: deleting it leaves both green. 04653 states as much itself, that the deferred filter runs without the index tokenizer rewrite so its expected results must not depend on it, which is exactly the property the sync controls. deferFiltersAfterFinalIfNeeded snapshots deferred_prewhere_info, and only after that does the text-index pass rewrite the PREWHERE and call updatePrewhereInfo. The isPrewhereDeferredAfterFinal gate in that pass suppresses only the direct-read/virtual-column half, so the tokenizer/preprocessor rewrite still fires on a deferred PREWHERE and the sync is what makes the post-FINAL filter use the rewritten DAG. The new case uses preprocessor = lower(text) with mixed-case data and a lower-case needle so that only the rewritten predicate matches. The predicate is duplicated in WHERE because a deferred PREWHERE is excluded from index analysis and text is not a sorting-key column, which makes the WHERE copy the only registrant of the text index; without it the rewrite never fires. use_skip_indexes and use_skip_indexes_if_final are pinned per statement because the runner randomizes the latter 50/50 and a false draw unregisters the index and would make the case silently vacuous rather than failing. With the sync reverted the new query returns nothing instead of one row while both controls and every pre-existing assertion stay green. Asserting the rewritten deferred filter in EXPLAIN is not possible: the deferred block prints only the filter's column name and the rewrite preserves that name, so EXPLAIN actions=1 is byte-identical with and without the sync. Related: ClickHouse#109703
Internal second-model review (click to expand)Two independent passes before publication: a cold code review by a reviewer that never saw the Outcome: 0 blockers, 0 majors. The second-model gate returned 0 findings over 💡 The
✅ Carriers checked independently and matched. All three ✅ Liveness holds structurally, not just empirically. ✅ Randomization exposure re-derived, including one axis the reviewer raised. ✅ No test tag is owed. Parallel replicas is structurally unavailable here because Session id: cron:clickhouse-review-slot-53:20260730-010200 |
Pre-PR validation gate (click to expand)
Extra hygiene: no Session id: cron:clickhouse-impl-slot-47:20260730-004200 |
|
cc @CurtizJ, could you review this? It is test-only. #109703 added a sync in ReadFromMergeTree::updatePrewhereInfo that carries a later text-index rewrite into deferred_prewhere_info, but neither test it shipped pins that line, because the text-index pass rewrites the PREWHERE after deferFiltersAfterFinalIfNeeded has already snapshotted it. This adds the case that reddens when the sync is removed, using a lower preprocessor so only the rewritten predicate matches. |
|
Workflow [PR], commit [cd2247e] Summary: ✅ AI ReviewSummaryThis PR adds a stateless regression test for the deferred- Final VerdictStatus: ✅ Approve |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #109703
Follow-up requested by @ yariks5s in #109703 (comment). Test-only, no source change.
#109703 added a sync in
ReadFromMergeTree::updatePrewhereInfothat carries a later PREWHERE rewrite intodeferred_prewhere_info. Neither test it shipped pins that line: deleting it leaves both green.04653says so itself, that the deferred filter runs without the tokenizer rewrite so its results must not depend on it, which is exactly the property the sync controls.deferFiltersAfterFinalIfNeededsnapshotsdeferred_prewhere_info, and only afterwards does the text-index pass rewrite the PREWHERE and callupdatePrewhereInfo. TheisPrewhereDeferredAfterFinalgate there suppresses only the direct-read half, so the preprocessor rewrite still fires on a deferred PREWHERE and the sync is what makes the post-FINAL filter use it.The new case uses
preprocessor = lower(text)with mixed-case data and a lower-case needle, so only the rewritten predicate matches. The predicate is duplicated inWHEREbecause a deferred PREWHERE is excluded from index analysis, making theWHEREcopy the only registrant of the text index; without it the rewrite never fires.use_skip_indexesanduse_skip_indexes_if_finalare pinned because the runner randomizes the latter 50/50 and a false draw unregisters the index and makes the case vacuous.Validation: with the sync reverted the new query returns nothing instead of one row, while both controls and every pre-existing assertion in
04653and04652stay green. Tag-free 50 of 50 runs pass.One note on the request: asserting the rewritten deferred filter in
EXPLAINis not achievable. The deferred block prints only the filter's column name, and the rewrite preserves that name, soEXPLAIN actions=1is byte-identical with and without the sync. The result-based case is shipped instead.Version info
26.8.1.420(included in26.8and later)