Repository navigation
Improve JSON subcolumn resolution with type hints on typed paths - #99179
Conversation
When a JSON column declares a typed path like json JSON(a Array(JSON)), the [] syntax sugar transforms json.a[].x into json.a.:Array(JSON).x. The type hint is redundant for typed paths and caused incorrect resolution. Detect and strip such redundant hints in getDynamicSubcolumnData by comparing type names after normalizing JSON parameters. Move typed paths enumeration inside the enumerate_dynamic_streams guard so all subcolumn requests go through this path.
…rray-object-subcolumn-magic
|
Workflow [PR], commit [168c537] Summary: ❌
AI ReviewSummaryThis PR improves JSON typed-path subcolumn resolution (especially Findings❌ Blockers
Tests
ClickHouse Rules
Performance & SafetyThe issue is primarily semantic correctness rather than raw performance: it can route subcolumn resolution through a branch that assumes the hint matched, even when the hint encoded a different JSON schema. Final Verdict
|
…rray-object-subcolumn-magic
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
…ouse/ClickHouse into json-array-object-subcolumn-magic
…rray-object-subcolumn-magic
…rray-object-subcolumn-magic
…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]>
LLVM Coverage Report
Changed lines: 95.59% (65/68) · Uncovered code |
It's not the blocker. It's expected. We need |
|
Hi @Avogar @thevar1able — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Allow
json.path[]syntax sugar and explicit type hints to work correctly on typed JSON paths.Documentation entry for user-facing changes
Note
Medium Risk
Touches JSON
DataTypeObjectsubcolumn parsing andSerializationObject::enumerateStreamsbehavior, which can affect subcolumn discovery/resolution across queries and serialization paths. Added logic is localized but involves nuanced string parsing (typed-path prefix matching and JSON-parameter normalization).Overview
Improves JSON subcolumn resolution for typed JSON paths so that nested access and
[]sugar behave consistently with dynamic paths, and redundant explicit type hints (e.g..:`Array(JSON)`) on typed paths are stripped when they match the declared typed-path type (after normalizing awayJSON(...)` parameters).This refactors subcolumn parsing to split requests by the longest typed-path prefix before falling back to parsing
.:`Type`markers, and addsremoveJSONTypeParameters()` to compare type hints robustly even when JSON parameters include back-quoted strings.Updates
SerializationObject::enumerateStreamsto only enumerate typed/dynamic/shared streams whenenumerate_dynamic_streamsis enabled, forcing JSON subcolumn requests to route throughDataTypeObject::getDynamicSubcolumnDatafor the new hint-stripping behavior. Adds stateless query tests covering typed-vs-dynamic parity, nested subcolumns on typed paths, mismatched hints, and JSON-parameter edge cases.Written by Cursor Bugbot for commit a699e56. This will update automatically on new commits. Configure here.
Version info
26.5.1.578