Repository navigation
Conversation
This reverts commit 338b873 (ClickHouse#110114), reversing changes made to 662a0a0. A filter pushed below the window can reach the probe side of a hash join, which is read only after the build side, so an always-false filter such as IN over an empty subquery no longer stops the query before the build (ClickHouse#123875). Conflict resolution: ClickHouse#122975 later changed the reverted branch; the whole branch is removed, its other call sites and its test stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 findings).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261012-171000 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261012-164900 |
|
Workflow [PR], commit [d55d182] Summary: ⏳
AI ReviewSummaryThis PR reverts the Final Verdict
LLVM Coverage Report |
|
📊 Cloud Performance Report
This PR removes one optimization: filters on PARTITION BY columns are no longer pushed below WindowStep. Only queries with window functions take that code path. The benchmark flagged one query, clickbench Q18, as +42.6% slower (824.5 ms to 1175.5 ms, with CPU time up by a similar amount). The shift is too large to override, so the regression verdict stays. However, Q18 is a plain GROUP BY with no window function and never reaches the changed code, and it has a history of noisy results on master. Most likely something other than this diff caused the slowdown, such as a different base commit or variance on the test machine. Re-run the benchmark before treating it as caused by this PR. clickbench🔴 1 regressed Flagged queries (1 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
|
Running the CI because this is not a plain revert. |
Both queries of ClickHouse#123875 must stop before the LEFT JOIN below the window reads its right side, which throws if it is read. They fail on master (the filter is pushed below the window to the join's left input) and pass with the revert. The early stop holds only for a hash join that builds the right table, without parallel replicas and with query_plan_merge_filters = 1, so the test pins those. Measured on the revert binary: parallel_hash, grace_hash, full_sorting_merge, parallel replicas and query_plan_merge_filters = 0 all read the right side, as before ClickHouse#110114. Co-Authored-By: Claude Opus 5.5 <[email protected]>
002a17c
Cherry pick #125463 to 26.8: Revert "Push filters below WindowStep on PARTITION BY columns"
Cherry pick #125463 to 26.9: Revert "Push filters below WindowStep on PARTITION BY columns"
Backport #125463 to 26.8: Revert "Push filters below WindowStep on PARTITION BY columns"
Backport #125463 to 26.9: Revert "Push filters below WindowStep on PARTITION BY columns"
…evert Master now short-circuits `throwIf(rk > 1) = 0 AND rk <= 1`: `throwIf` is not evaluated on the rows `rk <= 1` rejects, so case 30b's query no longer raises with the optimization off or on (measured on master 2cb89c8, which does not contain this change: it returns 3). Pin short_circuit_function_evaluation to 'disable' on both queries, which restores the exception in both arms and keeps the case able to catch a prefilter that drops the rows `throwIf` throws on. ClickHouse#110114 was reverted by ClickHouse#125463, so `p < 100` is no longer pushed below the window. The prefilter still declines that query, now because the filter computes `p < 100` beside the bound. Only the case label changes; the asserted count stays 0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…uch a condition The filter push-down does not pass a window any more (ClickHouse#125463), so neither a condition on the keys nor a runtime join filter restricted the generated window, which read and sorted the whole table. The pass now copies the deterministic conditions on the keys of the windows into the derived table, where they remove whole partitions only, and rewrites only when there is such a condition. The rule for conditions on tables joined on the keys, which relied on the runtime filter, is removed with its tests; the other tests get a condition on the key, so they still check the rewritten query.
Closes: #123875
Related: #110114
Related: #110109
Related: #123927
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A filter on the
PARTITION BYcolumns of a window function is no longer pushed below the window (this reverts #110114). The push-down made queries up to 8 times slower when the window reads aJOINand the filter removes every row, for exampleINover an empty subquery, because the join built its right side before the filter could stop the query. Closes #123875.Description
Reverts #110114, as requested in #123875 (comment); #110109 is to be reopened.
#110114 lets a
WHEREonPARTITION BYcolumns pass the window step, and join push-down then moves it to the hash join's left input. A hash join reads that input only after building its right side, so an always-false filter such asc1 IN (SELECT ... FROM empty_table)no longer stops the query before the build. Results were never wrong.Issue queries (
compatibility = '24.12', max_threads = 8), master CI release binaries before (662a0a0) and after (28ab4b6) #110114, median of 5:LEFT JOIN, outerINrn = 1 AND c1 IN (...)LEFT JOIN, no windowThe revert does not apply cleanly: #122975 later added
allow_index_hints = falseto the removed call. The whole window branch is removed; #122975's other call sites and its test stay. The test of #110114 is deleted. The new test05393_window_over_join_empty_in_setruns both issue queries with a join right side that throws if it is read: it fails on master and passes with the revert.Validation (debug build, both binaries): with the revert, both issue queries do no join build again and read the same
SelectedRowsas the build before #110114, with identical results. The deleted test's push-down probes flip from 1 to 0, its correctness rows are unchanged. 291 window andQUALIFYstateless tests give identical pass/fail sets with and without the revert, randomized and deterministic.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125463]
Version info
26.10.1.2262-master(included in26.10and later)26.9.19.14,26.8.27.14