Skip to content

Revert "Revert "Filter PartsSplitter layers on the key columns the sorting expression computed"" - #125827

Merged
alexey-milovidov merged 6 commits into
masterfrom
revert-125763-revert-120058-fix/parts-splitter-layer-filter-key-columns
Oct 22, 2026
Merged

alexey-milovidov merged 6 commits into
masterfrom
revert-125763-revert-120058-fix/parts-splitter-layer-filter-key-columns

Conversation

@KochetovNicolai

@KochetovNicolai KochetovNicolai commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Reverts #125763


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

Version info

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

@clickhouse-gh

clickhouse-gh Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4450985]

Summary: ✅


AI Review

Summary

This PR restores PartsSplitter layer filtering against the table's stored key expression, preventing rows from disappearing when session settings change a key expression's result type. It also fixes alias resolution for stored primary keys and prunes unused key suffix computations for sharded joins. Reviewed head 4450985efdb390f8111491ed68e1fd518c081437, the current code, and all prior discussion. Both earlier findings are addressed; no new actionable findings remain. All three added regression tests pass in the Fast test report and locally using that commit's binary.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 14, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... label Oct 14, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 15, 2026
alexey-milovidov and others added 2 commits October 16, 2026 06:11
…t-120058-fix/parts-splitter-layer-filter-key-columns
…une unused key computations

The layer filter of `PartsSplitter` refers to the key columns by `column_names`, which are alias-free,
but it was resolved against `primary_key.sample_block`, whose names carry the aliases of the key
(`PRIMARY KEY (k AS a)`), so a layered `FINAL` read threw `UNKNOWN_IDENTIFIER`. Resolve it against
`column_names` paired with `data_types` instead.

Composing the filter with the whole key expression kept the computations of the key columns the filter
does not use, and `reorderColumns` replaced the outputs without pruning them. The join-by-shards layers
split on the common prefix of the join keys and read only the query's columns, so a computed key suffix
(`toDate(b)`) required an unread column and threw `NOT_FOUND_COLUMN_IN_BLOCK`. Call
`removeUnusedActions` after `reorderColumns`.

Related: #125549
Related: #125550

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

clickhouse-gh Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 4450985ef with master 9ce1640e2 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of a4ab3777d; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 13 s compile time in total, 7 of them have a recent master baseline.

Job report

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125827&sha=391aadc3138036028407227f53c82e2513a11d31&name_0=PR&name_1=Unit%20tests%20%28asan_ubsan%2C%20function_prop_fuzzer%29 (FunctionsStress.stress: a worker stuck in __asan_stack_malloc_1 while running range) and provide a fix in a separate PR. If the fix is already in progress, link it here. It looks like #126210 may cover it.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is in progress: #126210. The stuck worker at 391aadc3 (146.3 s on range(materialize(CAST(11720145 AS Int32)))) has the same stack as the other occurrences: __asan_stack_malloc_1 <- PODArray::operator[] <- ColumnVector::doCompareAt <- ColumnArray::compareAtImpl <- FunctionsStressTestThread::executeFunction.

Mechanism: #120908 (comment). #126210 changes only the test harness; its CI has finished and it is mergeable, waiting for a review.

CIDB: 24 occurrences since 2026-10-15 (3 on master), 0 in the 640 runs of 2026-10-14.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Merged master to pull in #126345, which fixes the flaky 03821_drop_workload_during_query_race seen in the last run. The remaining failure, Upgrade check (amd_release) (MutatePlainMergeTreeTask retrying UNKNOWN_IDENTIFIER on all_1_1_1_2), is unrelated to this PR: it is #120975, and its fix #125293 is still open. @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125827&sha=80293494055419bc7e740a4d5c43e6f2c9d4a8bb&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 and help get the fix merged. If another fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

This is #120975, and #125293 is the only fix in progress. All 150 lines of upgrade_error_messages.txt come from test_3.t_stale_part_type_5 (04653_mutation_rewrite_stale_part_column_type). The upgraded server loads the empty part all_1_1_1 that DETACH PART left on disk as active, and retries its mutation to version 2 50 times until cleanup drops the part 38 s after loading it. The previous release in this run was v26.9.21.9-stable.

I checked #125293 on the server version this check uses: I ran 04653 on a v26.9.22.3-stable server, then restarted the same data directory with a master build.

#125293 is green and mergeable, and its one review thread is resolved, but no maintainer has reviewed it since it opened on 2026-10-12. I can't approve or label PRs here, so it needs a maintainer to approve and merge it with v26.9-must-backport and v26.10-must-backport. Merging to master alone does not change this check, because the check runs the previous release's copy of the tests (#111392 (comment)). 04653 is byte-identical on master, 26.9 and 26.10, so both cherry-picks apply cleanly. Each run picks the newest release older than the PR build, so the first 26.9 release with the backport fixes it for all PRs without a master merge. 26.10 needs it before its first stable is tagged.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 21, 2026
…metadata

Master now refuses an alias in `PRIMARY KEY` of a new table (`KeyDescription::checkNoAlias`),
so `CREATE TABLE ... PRIMARY KEY (k AS a)` failed with `BAD_ARGUMENTS` and broke the merge queue.
Such a key still comes from the metadata stored by an older server, so the aliased-key case moves
to a `.sh` test that edits the stored metadata of a `clickhouse-local` table, as
`05301_storage_key_alias_stored_definition` does. The remaining test is renamed after what it covers.

Merge queue run: https://github.com/ClickHouse/ClickHouse/actions/runs/39646520885
PR: #125827

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 22, 2026
Merged via the queue into master with commit 2211c10 Oct 22, 2026
178 checks passed
@alexey-milovidov
alexey-milovidov deleted the revert-125763-revert-120058-fix/parts-splitter-layer-filter-key-columns branch October 22, 2026 17:38
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-query-optimizer Query plan optimization: physical plan steps, plan-level rewrites and optimizations (QueryPlan pa... pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants