Skip to content

Iterate ColumnObject subcolumns in sorted path order - #112601

Merged
Avogar merged 1 commit into
masterfrom
fix-column-object-subcolumn-order
Aug 10, 2026
Merged

Avogar merged 1 commit into
masterfrom
fix-column-object-subcolumn-order

Conversation

@Avogar

@Avogar Avogar commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Make ColumnObject::forEachSubcolumn, forEachMutableSubcolumn and their recursive variants iterate over the already-maintained sorted_typed_paths/sorted_dynamic_paths lists instead of the raw typed_paths/dynamic_paths unordered_maps.

Motivation: the iteration order of an unordered_map is not guaranteed to be preserved by its copy constructor, and IColumn::mutate clones the column (copy-constructing those maps) when it is shared. IColumn::convertToFullIfWrapped collects the unwrapped subcolumns while iterating the source column and then reassigns them positionally while iterating the mutated (possibly cloned) column, so both passes must visit subcolumns in the same order. If the cloned maps iterated in a different order, converted subcolumns would be assigned to the wrong paths.

Iterating the sorted path lists makes the visiting order deterministic and stable across cloning, removing the reliance on unspecified unordered_map copy-order behavior. This is currently latent — the bundled libc++ happens to preserve copy order — so it is a safety change with no user-visible effect.

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):

...

🤖 Generated with Claude Code

Version info

  • Merged into: 26.8.1.1131 (included in 26.8 and later)
  • Backported to: 26.7.4.17, 26.6.3.32, 26.5.7.40, 26.3.18.22, 25.8.30.14

`ColumnObject::forEachSubcolumn`, `forEachMutableSubcolumn` and their
recursive variants iterated the raw `typed_paths`/`dynamic_paths`
`unordered_map`s. The iteration order of an `unordered_map` is not
guaranteed to be preserved by its copy constructor, and `IColumn::mutate`
clones the column (copy-constructing those maps) when it is shared.

`IColumn::convertToFullIfWrapped` collects the unwrapped subcolumns while
iterating the source column and then reassigns them positionally while
iterating the mutated (possibly cloned) column, so the two passes must
visit subcolumns in the same order. If the cloned maps iterated in a
different order, converted subcolumns would be assigned to the wrong
paths.

Iterate the already-maintained `sorted_typed_paths`/`sorted_dynamic_paths`
instead, so the visiting order is deterministic and stable across cloning.
This is currently latent (the bundled `libc++` happens to preserve copy
order), so it is a safety change and not user-visible.

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

clickhouse-gh Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [40301f7]

Summary: ✅


AI Review

Summary

This PR makes ColumnObject::forEachSubcolumn / forEachMutableSubcolumn iterate subcolumns in deterministic path order instead of relying on unordered_map iteration order after a shallow clone. The implementation looks directionally correct, but the PR still lacks the focused regression test that would prove the shared convertToFullIfWrapped path no longer reassigns subcolumns to the wrong paths.

Tests
  • ⚠️ src/Columns/ColumnObject.cpp changes a latent correctness invariant in IColumn::convertToFullIfWrapped, but there is no regression coverage for the exact shared-clone path described in the PR. Please add a unit test that shares a ColumnObject, forces at least one wrapped subcolumn to materialize during convertToFullIfWrapped, and verifies that typed and dynamic paths keep their original values after reassignment.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required action: add the focused regression test for the shared convertToFullIfWrapped / IColumn::mutate path that this patch is intended to fix.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 30, 2026
@Avogar Avogar added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jul 30, 2026
Comment thread src/Columns/ColumnObject.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.60% 78.60% +0.00%

Changed lines: Changed C/C++ lines covered: 20/31 (64.52%) · Uncovered code

Full report · Diff report

@kssenii kssenii self-assigned this Aug 10, 2026
@Avogar
Avogar added this pull request to the merge queue Aug 10, 2026
Merged via the queue into master with commit b3f1e93 Aug 10, 2026
179 checks passed
@Avogar
Avogar deleted the fix-column-object-subcolumn-order branch August 10, 2026 19:52
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 10, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 10, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 10, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Aug 10, 2026
clickhouse-gh Bot added a commit that referenced this pull request Aug 10, 2026
Backport #112601 to 26.7: Iterate ColumnObject subcolumns in sorted path order
alexey-milovidov added a commit that referenced this pull request Aug 12, 2026
Backport #112601 to 26.5: Iterate ColumnObject subcolumns in sorted path order
alexey-milovidov added a commit that referenced this pull request Aug 12, 2026
Backport #112601 to 26.3: Iterate ColumnObject subcolumns in sorted path order
alexey-milovidov added a commit that referenced this pull request Aug 12, 2026
Backport #112601 to 25.8: Iterate ColumnObject subcolumns in sorted path order
kssenii added a commit that referenced this pull request Aug 13, 2026
Backport #112601 to 26.6: Iterate ColumnObject subcolumns in sorted path order
VighneshPath pushed a commit to VighneshPath/ClickHouse that referenced this pull request Aug 24, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
VighneshPath pushed a commit to VighneshPath/ClickHouse that referenced this pull request Sep 16, 2026
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
JSON: ColumnObject iterated its typed/dynamic path columns in hash-map order -> JSON join keys with several paths miss in the exact-values runtime filter.
Effect in the production build a394e92: without it the 04327_join_runtime_filter_json case with two JSON paths still returns 0 after the ClickHouse#107663 backport (a33ab46) on the candidate 91efe1f244ce, deterministically and with join_runtime_filter_exact_values_limit = 0 as the only workaround; official 26.8.8.8 returns 1. The 26.3 branch merged this backport (ClickHouse#114224, 2026-08-12) before the ClickHouse#107663 backport (ClickHouse#109074, 2026-09-05), so the upstream test passed there.
Upstream patch unchanged, with its test(s): -.
No test of its own; 04327_join_runtime_filter_json (from the ClickHouse#107663 backport) is the regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
…f upstream fixes

The stateless selection gets the upstream tests of the 34 backports of the residual audit
and of the two backports they depend on (ClickHouse#99085, ClickHouse#107562), 04627 (runnable with the gate's
loopback Keeper), and 10317/10318 (Parquet Decimal512): 152 tests. 04670 (needs pyarrow) and
00900 (a long load test whose skip list changed) run outside the gate.

known_defects.json: a fixed KD-UP entry per backport (fixed_by = its commit); KD-UP-108790
points at the ClickHouse#115705 backport, which carries its change; KD-UP-107663 records its ClickHouse#112601
dependency. Defects found by the release gate on the candidate 91efe1f244ce and fixed:
KD-D512-PERF-OVERFLOW-CHECKS (e91167f), KD-TEST-BLOCKCHAIN-TYPENAME (f006d0d),
KD-GATE-NO-KEEPER (095b89c). 80 entries, 0 open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

5 participants