Repository navigation
Conversation
`getNameForSubstreamPath` rendered the `Array`, `Nullable` and `JSON` container
substreams as nothing, so a nested user-provided name could collide with an
automatically generated one: both streams of ``Array(Tuple(`size0` UInt64))``
competed for `size0`, and a `JSON` path named `object_structure` was written into
the same file as the column's structure stream, corrupting the part.
Add `substream_naming_version`. Under `namespaced` every container substream opens
a namespace in the file name - `arr_elems`, `null_elems`, `object_paths` - which
makes the name injective, so those collisions cannot happen. `TupleElement` uses a
uniform separator, and the level number is dropped from `.size` because
`ArrayElements` already opens a namespace per level.
Each part records the scheme it was written with as a top-level
`substream_naming_version` key in `serialization.json`, independent of
`serialization_info_version`: a part using the non-default scheme persists it even
when there is nothing else to record. The two are forward compatibility knobs at
the same level, so neither overrides the other. Readers take the scheme from the
part, so parts written under either scheme coexist in one table and survive
merges, mutations and renames.
Null maps are numbered per `Nullable` level since the last emitted component
(`.null`, `.null1`, ...), which makes the `Nullable(Array(...))` chains
expressible before that type is supported.
The substreams cache is keyed by the full stream file name rendered in the
namespaced form, which is injective for every type. One cache therefore serves
every column of a read, and the flattened `Nested` prefix redirect makes a group's
columns meet on the shared offsets stream on its own. The wide reader resolves
physical columns and no longer needs the collected `Nested` view, which is deleted
along with the `share_nested_offsets` flag in the part-columns interning key.
Includes the not-yet-merged subcolumn resolution work this depends on: a subcolumn
name resolves to a substream declared in the type, then to a dynamic one, then to
a generated name, with the listing and the lookup following the same rules in
`subcolumnResolution.{h,cpp}`. `Substream::NullMapHidden` becomes redundant and is
deleted, which is what makes every null map of a chain reachable as a subcolumn.
The default is temporarily `namespaced` so that CI reports every test that pins a
stream file name. It goes back to `basic` before merge, with randomization added
in its place.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`optimize_functions_to_subcolumns` name collision (#115777) merged into master after this branch was cut, so its files exist on both sides. Master's versions win there, including the `memory-engine` tag added to `04935_optimize_functions_to_subcolumns_name_collision` afterwards. `IDataType::getSubcolumnInfo` keeps this branch's body, which delegates to `SubcolumnResolution::findSubcolumn`; master's inline implementation and its `makeSubcolumnInfo` helper are superseded by `subcolumnResolution.cpp`, which populates the same `substreams_path`. In `IMergeTreeDataPart::getCompressionCodecForPart` the two sides changed adjacent lines: master added a warning when no data file is found, this branch takes the naming scheme from the part. Both are kept. `MergeTreeData.cpp` loses both conflicting includes: master dropped `absl/container/inlined_vector.h` and this branch made `boost/container_hash/hash.hpp` unused by removing `collect_nested` from the part-columns interning key. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [b888182] Summary: ❌
|
`src/TableFunctions` is linted against `std::` containers so that allocations are tracked. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Avogar
added a commit
to Avogar/ClickHouse
that referenced
this pull request
Sep 16, 2026
The case asserting that a purely bucketed `Map` configuration stays allowed also has to pin `serialization_info_version = 'with_types'`. Per-type serialization versions are only recorded in `serializations.json` from that version on, so with `basic` the nested `Map` falls back to `basic` serialization, writes a plain `keys` stream and really does collide with the user-supplied `a.keys` element. CI randomizes the setting, which is why the case failed there while the check was right to reject it. Also drop the claim that no detection is lost by not enumerating dynamic streams. It does not hold: the shared data of `Object` renders its `paths` and `values` components as escaped-dot names (`object_shared_data%2Epaths`), so a declared `JSON` path of that name collides with them under `object_shared_data_serialization_version = 'map'` and is not caught here. `basic` stream naming is simply not injective; making it so is the subject of ClickHouse#119329. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…aming Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. - retargeted PR record [email protected] to 26.10 (settings-history check rule) - semantic merge fixes in non-conflicting files: src/DataTypes/subcolumnResolution.cpp Also resolved conflicts in: - `src/DataTypes/IDataType.cpp` - `src/DataTypes/IDataType.h` - `src/DataTypes/Serializations/ISerialization.cpp` - `src/DataTypes/Serializations/ISerialization.h` - `src/DataTypes/Serializations/SerializationObjectSharedData.cpp` - `src/Storages/MergeTree/MergeTreeData.cpp` - `src/Storages/MergeTree/MergeTreeDataPartWide.cpp` - `src/Storages/MergeTree/MergeTreeReaderWide.cpp` - `src/Storages/StorageLog.cpp` - `tests/queries/0_stateless/04927_substreams_cache_key_collision.sql` Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on: #115670
Depends on: #115777
Depends on: #116393
Related: #115632
Stream file names of Wide parts are not injective: the
Array,NullableandJSONcontainer substreams contribute nothing to the name, so a nested user-provided name can collide with an automatically generated one. Both streams ofArray(Tuple(`size0` UInt64))compete forsize0, and aJSONpath namedobject_structurelands in the same file as the column's structure stream, which corrupts the part.This adds the
substream_naming_versionMergeTree setting. Undernamespacedevery container substream opens a namespace in the file name (arr_elems,null_elems,object_paths),TupleElementuses a uniform separator, and the level number is dropped from.sizebecauseArrayElementsalready opens a namespace per level. Names become injective, so those collisions become impossible and schemas that are rejected or silently corrupt a part today —`a.b` UInt64besidea Tuple(b UInt64), or aJSONpath namedobject_structure— become valid and correct.Each part records the scheme it was written with, as a top-level
substream_naming_versionkey inserialization.jsonthat is independent ofserialization_info_version; the two are forward compatibility knobs at the same level, so neither overrides the other. Readers take the scheme from the part, so parts written under either scheme coexist in one table and survive merges, mutations, renames and reattach.Null maps are numbered per
Nullablelevel since the last emitted component (.null,.null1, ...), which makes theNullable(Array(...))chains expressible ahead of support for that type.The substreams cache is keyed by the full stream file name in the namespaced form, which is injective for every type, so one cache serves every column of a read and a flattened
Nestedgroup's columns meet on the shared offsets stream on their own. The wide reader therefore resolves physical columns and no longer needs the collectedNestedview.The subcolumn name resolution work from the pull requests listed above is included here because it cannot be separated: it deletes
Substream::NullMapHidden, and without that not every null map of a chain is reachable as a subcolumn. Following the no-stacked-pull-request rule, the dependency is carried in this PR rather than the branch being based on those.The default is temporarily
namespacedso that CI reports every test that pins a stream file name. Before merge it returns tobasic, withsubstream_naming_versionadded to the test settings randomizer instead.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added the
substream_naming_versionMergeTree setting. Withnamespaced, every container substream of a Wide part opens its own namespace in the stream file name, which makes the names injective and removes collisions between automatically generated names and user-provided ones — for example aTupleelement or aJSONpath namedsize0,nullorobject_structure. Each part records the scheme it was written with, so changing the setting affects only new parts and existing parts stay readable.Workflow [PR]
Sync PR [sync-upstream/pr/119329]