Repository navigation
Re-land sparse serialization for typed paths of JSON columns, with a fix for the text-format INSERT crash - #133564
Conversation
…aths declared inside `JSON` columns."" Re-applies ClickHouse#111429 by @ rorylshanks (merge b6f0aca), reverted in ClickHouse#133486 because a text-format INSERT into a `serialization_info_version = 'with_subcolumns'` table crashed the server (ClickHouse#133480). This commit is the pure re-land (`git revert -m 1 fff0c72`); the fix for ClickHouse#133480 follows in the next commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n hints With `serialization_info_version = 'with_subcolumns'` (ClickHouse#111429) the table's serialization hints carry a kind per `JSON` typed path. The hints are built only to be passed to input formats (`IRowInputFormat::setSerializationHints`), so a text-format INSERT (`file`/`url`/`s3`/object storage reads, HTTP and inline data) created a `ColumnSparse` inside the typed-path slot of `ColumnObject`, and the `JSON` text parser (`JSONExtractTree`), which builds its nodes from the type and inserts into dense column classes at every nesting level, wrote into it: a bad `assert_cast` abort in debug builds, a NULL write / heap corruption in release (ClickHouse#133480). Cap the version of the hints at `with_missing_columns` in `MergeTreeData::buildSerializationHints`, the hints' single producer, so no hint ever describes a typed path and input formats always create dense typed paths. Written parts still choose the typed-path kinds from their data, so a part written by such an INSERT still stores a mostly-default typed path `Sparse`. `updateSerializationHintsForPart` already skips a part whose info structure differs from the hint (now the case for every `JSON` column, and for a `Tuple` containing one, of such a table), so the incremental updates keep the cap. The test covers a plain `JSON` column (`JSONEachRow` and `TSV`), `JSON` inside a top-level `Tuple`, and a typed path of `Tuple` type; each aborts without the fix. Closes ClickHouse#133480 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 findings, all on the re-landed #111429 code; none on the fix commit).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261122-161800 |
|
cc @rorylshanks, could you review this? It re-lands #111429 (sparse typed paths in JSON) and fixes the text-format INSERT crash #133480 by capping the version of MergeTreeData::buildSerializationHints at with_missing_columns, so input formats never create a sparse typed path for the JSON text parser. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261122-153500 |
|
Workflow [PR], commit [9c1f064] Summary: ❌
AI ReviewSummaryReintroduces opt-in sparse serialization for declared Consumers traced for the new sparse representation: input formats receive capped hints; scalar functions, aggregation, sorting/merging, and squashing use recursive materialization; subcolumn/sub-object readers create columns matching their serializations; row output derives serialization from the actual columns; All 12 added/restored SQL tests matched their references using the PR's ARM fast-test binary. Focused probes passed for nested schema evolution, tuple reordering, merges, metadata-version downgrade, sorting, and Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes1054 object files changed (+308.41 KiB total), 2 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units435 translation units recompiled, 2500 s compile time in total, 435 of them have a recent master baseline. |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=4 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
CI finish ledger - 9c1f064Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other ownable Session id: cron:our-pr-ci-monitor:20261122-203024 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Typed paths in
JSONcolumns can now use sparse serialization in MergeTree parts whenserialization_info_version = 'with_subcolumns', reducing CPU and memory usage when scanning mostly absent paths.Description
Re-applies #111429 by @ rorylshanks (reverted in #133486), plus the fix for the crash it caused, #133480.
Closes #133480. Related: #111429, #133486.
Root cause. With
with_subcolumns, the table's serialization hints (MergeTreeData::buildSerializationHints) carry a kind perJSONtyped path. They exist to feed input-format parsing (IRowInputFormat::setSerializationHints), so a text-format INSERT (file/url/s3reads; HTTP or inline data withasync_insert = 0) created aColumnSparseinside a typed path, and theJSONtext parser (JSONExtractTree), which fills dense columns only, wrote into it:Bad cast from type DB::ColumnSparse to DB::ColumnStringin debug builds, a NULL write or heap corruption in release.Change. Commit 1 is the pure re-land (
git revert -m 1 fff0c72d1ffb, same patch-id as #111429). Commit 2 caps the version of the hints atwith_missing_columns, so no hint describes a typed path and input formats create dense typed paths. Written parts still choose their kinds from the data, so a part written by such an INSERT still stores a mostly absent typed pathSparse; only parsing straight into sparse typed paths is not done. A top-levelTuplewith aJSONelement in such a table gets no hint either.Validation. New test
05857_json_typed_path_sparse_text_input_hints(plainJSONfromJSONEachRowandTSV,JSONin a top-levelTuple, aTupletyped path) aborts on commit 1 and passes 50/50 randomized runs with the fix. An HTTP inline-data INSERT kills the server on commit 1 and succeeds with the fix. The 12 tests of #111429 pass 10/10 each.The crash was only on master, never in a release.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/133564]