Skip to content

Fix exact subcolumn match priority over prefix match in getSubcolumnData - #101645

Merged
alexey-milovidov merged 5 commits into
masterfrom
fix-idatatype-exact-match-priority
Apr 13, 2026
Merged

alexey-milovidov merged 5 commits into
masterfrom
fix-idatatype-exact-match-priority

Conversation

@Avogar

@Avogar Avogar commented Apr 2, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix exact subcolumn match priority over prefix match in getSubcolumnData to avoid possible crash. Closes #101271

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Backported to: 26.3.9.4

…Data`

In `IDataType::getSubcolumnData`, the `!res` guard on the exact-name branch
prevented an exact match from overriding a `res` already set by the prefix
(dynamic subcolumn) branch. Because subcolumns are iterated in sorted order,
a Tuple element `a` (JSON) would match as a prefix of `a.b` and set `res`,
then the exact match on element `a.b` (UInt32) would be skipped, causing a
server exception via `ColumnDynamic::setVariantType`.

Fix: track `res_from_exact_match` separately. Exact matches always override
any prior prefix match; prefix matches are only taken when no exact match has
been found yet.

Fixes #101271
Extracted from #99179

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bf8dcb4]

Summary: ✅


AI Review

Summary

This PR fixes subcolumn resolution in IDataType::getSubcolumnData so exact-name matches are preferred over prefix-based dynamic-subcolumn matches, which prevents incorrect path selection and the resulting exception in dotted tuple-element cases such as a vs a.b. The change is small, targeted, and includes a focused stateless regression test that reproduces the scenario. I did not find correctness, safety, or performance issues in the patch.

Missing context
  • ⚠️ No CI logs or runtime test results were provided in the review inputs, so validation here is limited to static analysis of the diff and added test.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Apr 2, 2026
@antaljanosbenjamin antaljanosbenjamin self-assigned this Apr 2, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

@alexey-milovidov

Copy link
Copy Markdown
Member

The Can't adjust last granule error in CI is a known issue. The fix is in #101641

@alexey-milovidov

Copy link
Copy Markdown
Member

The flaky check failure is fixed in #102148, let's update the branch.

@clickhouse-gh

clickhouse-gh Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.10% +0.10%
Functions 90.80% 90.90% +0.10%
Branches 76.50% 76.60% +0.10%

Changed lines: 100.00% (16/16) | lost baseline coverage: 1 line(s) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Apr 13, 2026
Merged via the queue into master with commit 203f8dd Apr 13, 2026
164 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-idatatype-exact-match-priority branch April 13, 2026 05:56
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @Avogar @alexey-milovidov @antaljanosbenjamin — the changelog category for this PR might need a look.

Current: Bug Fix (user-visible misbehavior in an official stable release)
Suggested: Critical Bug Fix (crash, data loss, RBAC) or LOGICAL_ERROR

Why: Running the PR's own test on the pre-fix binary produces a SIGSEGV (Segmentation fault signal 11) in ColumnDynamic::setVariantType, crashing the server process. This is a crash, not merely user-visible misbehavior, and should be categorized as Critical Bug Fix.

Could you verify this is correct? Ignore if the current category is intentional.

@robot-ch-test-poll4 robot-ch-test-poll4 added pr-synced-to-cloud The PR is synced to the cloud repo pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Apr 13, 2026
robot-clickhouse added a commit that referenced this pull request Apr 13, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Apr 13, 2026
Avogar added a commit that referenced this pull request Apr 13, 2026
Backport #101645 to 26.3: Fix exact subcolumn match priority over prefix match in `getSubcolumnData`
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-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.3-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getSubcolumnData else-if dynamic branch overwrites res, !res guard on exact match prevents correction → wrong results and crash

6 participants