Skip to content

Resolve a shared data path's subcolumn from the path's own root - #120039

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-advanced-shared-data-subcolumn-serialization
Sep 18, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-advanced-shared-data-subcolumn-serialization

Conversation

@Avogar

@Avogar Avogar commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Closes: #119726
Related: #113752

The shared data stores each JSON path as a separate column, so the names of its substreams count Array wrappers from the Dynamic, while the serialization the reader was given had been resolved inside the types enclosing the Object and counts them from the column. Reading a sizeN subcolumn of a path that lives in shared data then asked the substreams list for a name it does not hold:

CREATE TABLE t (jd Array(JSON(max_dynamic_paths=1))) ENGINE = MergeTree ORDER BY tuple();
INSERT INTO t FORMAT JSONEachRow {"jd":[{"b":1,"zz":[[1,2],[3]]}]}

SELECT jd.zz.:`Array(Array(Nullable(Int64)))`.size1 FROM t;
-- Code: 49. DB::Exception: Substream .Array(Array(Nullable(Int64))).size1 for path zz
-- is requested but not found in substreams list (LOGICAL_ERROR)

This affects every part written with the advanced shared data serialization version, which is the default for merged parts, so the read starts failing as soon as a part is merged. Selecting the whole path alongside the subcolumn hid it, because that reads the path and extracts the subcolumn in memory instead of reading its substreams.

The subcolumn is now resolved against the Dynamic type, the root the data was written with. The dynamic path branch keeps the serialization it was given: there the enclosing wrappers are part of the reader's substream path, so the number it carries is the right one.

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

Fixed LOGICAL_ERROR when reading a sizeN subcolumn of a JSON path stored in shared data, for example jd.zz.:`Array(Array(Nullable(Int64)))`.size1. It affected parts written with the advanced shared data serialization version, which is the default for merged parts.


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

The shared data stores each path as a separate column, so the names of
its substreams count `Array` wrappers from the `Dynamic`, while the
serialization the reader was given had been resolved inside the types
enclosing the `Object` and counts them from the column. Reading a
`sizeN` subcolumn of a path in shared data then asked the substreams
list for a name it does not hold and threw `LOGICAL_ERROR`, on every
part using the `advanced` serialization version - the default for
merged parts.

Resolve the subcolumn against the `Dynamic` type instead, which is the
root the data was written with. The dynamic path branch keeps the
serialization it was given: there the enclosing wrappers are part of
the reader's substream path, so the number it carries is the right one.

Closes: #119726

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [884f5b5]

Summary: ✅


AI Review

Summary

This PR fixes direct reads of sizeN subcolumns from JSON paths that live in shared_data under the advanced serialization by resolving the subcolumn serialization from the path's own Dynamic root instead of the enclosing column root. I did not find a remaining correctness, compatibility, or coverage issue in the current diff.

Final Verdict

✅ No blocking or major issues found.

LLVM Coverage Report

Measured on commit 884f5b5.

Metric Baseline Current Δ
Lines 89.10% 89.10% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.50% 81.50% +0.00%

Changed lines: Changed C/C++ lines covered: 10/10 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... labels Sep 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 884f5b514 with master 0642d3da7 (stripped binary size, per-symbol sizes and ThinLTO time; 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

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

Job report

@alexey-milovidov alexey-milovidov self-assigned this Sep 18, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 18, 2026
Merged via the queue into master with commit 23265e7 Sep 18, 2026
176 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-advanced-shared-data-subcolumn-serialization branch September 18, 2026 11:34
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... pr-bugfix Pull request with bugfix, not backported by default 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.

sizeN fix misses advanced shared data: LOGICAL_ERROR persists on merged parts

3 participants