Make convertToFullIfNeeded recursive for compound column types#97493
Merged
alexey-milovidov merged 6 commits intomasterfrom Feb 22, 2026
Merged
Make convertToFullIfNeeded recursive for compound column types#97493alexey-milovidov merged 6 commits intomasterfrom
alexey-milovidov merged 6 commits intomasterfrom
Conversation
`IColumn::convertToFullIfNeeded` only converted the outermost column (const, replicated, sparse, low cardinality) but did not recurse into subcolumns of compound types like `ColumnTuple`, `ColumnArray`, `ColumnNullable`, etc. This caused assertion failures in debug/sanitizer builds when `Set::appendSetElements` or `MergeTreeIndexAggregatorSet::update` processed batches from different MergeTree parts that had different sparse serialization profiles for inner tuple elements. The fix uses `forEachSubcolumn` to recursively convert all inner columns, which generically handles all compound column types. Closes #97474 Closes #97335 https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97431&sha=6fe0e8c44dd5c6a12583390b4f8fc45e226a3cb4&name_0=PR&name_1=Stateless%20tests%20%28arm_asan%2C%20azure%2C%20parallel%29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
The test creates a MergeTree table with a Tuple column where different parts have different sparse serialization profiles for inner elements, then uses `IN` with a subquery to trigger `Set::appendSetElements` which previously failed with an assertion because `ColumnTuple` inner columns were not recursively converted from sparse to full. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| @@ -0,0 +1,27 @@ | |||
| -- Tags: no-random-merge-tree-settings | |||
Member
Author
There was a problem hiding this comment.
Does not reproduce.
Member
Author
There was a problem hiding this comment.
Ok, now it does.
The assertion in `ColumnTuple::doInsertRangeFrom` only fires when the destination is non-sparse (`ColumnVector`) and the source is sparse (`ColumnSparse`), because `ColumnSparse::doInsertRangeFrom` handles both cases. Swap insert order so the non-sparse part (all_1_1_0) is read first into `set_elements`, and the sparse part comes second. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
`Set::appendSetElements` is only called when `fill_set_elements` is true, which happens when `KeyCondition` calls `buildOrderedSetInplace` for index evaluation. The IN column must be part of the ORDER BY key for this to happen. Changed `ORDER BY key` to `ORDER BY val` so that the tuple column is in the primary key and `KeyCondition` triggers the `buildOrderedSetInplace` path. Verified: aborts on unpatched debug build (exit code 134), passes on patched. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avogar
approved these changes
Feb 20, 2026
This was referenced Feb 22, 2026
Closed
Closed
robot-ch-test-poll4
added a commit
that referenced
this pull request
Feb 22, 2026
Cherry pick #97493 to 25.11: Make convertToFullIfNeeded recursive for compound column types
robot-ch-test-poll4
added a commit
that referenced
this pull request
Feb 22, 2026
Cherry pick #97493 to 25.12: Make convertToFullIfNeeded recursive for compound column types
This was referenced Feb 22, 2026
Merged
robot-ch-test-poll4
added a commit
that referenced
this pull request
Feb 22, 2026
Cherry pick #97493 to 26.1: Make convertToFullIfNeeded recursive for compound column types
clickhouse-gh bot
added a commit
that referenced
this pull request
Feb 22, 2026
Backport #97493 to 25.12: Make convertToFullIfNeeded recursive for compound column types
clickhouse-gh bot
added a commit
that referenced
this pull request
Feb 22, 2026
Backport #97493 to 25.11: Make convertToFullIfNeeded recursive for compound column types
alexey-milovidov
added a commit
that referenced
this pull request
Feb 22, 2026
The `concat` function's `executeFormatImpl` called `convertToFullIfNeeded` which, after it was made recursive in #97493, strips `LowCardinality` from inside compound column types like `Variant`. However, the argument type is not updated to match, so `SerializationLowCardinality` tries to cast a non-LC column, triggering a LOGICAL_ERROR exception in debug builds. Fix by using only top-level column conversions (Const, Sparse, LowCardinality) instead of the recursive `convertToFullIfNeeded`, keeping the column structure consistent with the type's serialization. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97581&sha=320e7c9d8876b04a971bd26214b9ac0ab433c250&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 tasks
alexey-milovidov
added a commit
that referenced
this pull request
Feb 23, 2026
The `concat` function's `executeFormatImpl` called `convertToFullIfNeeded` which, after it was made recursive in #97493, strips `LowCardinality` from inside compound column types like `Variant`. However, the argument type is not updated to match, so `SerializationLowCardinality` tries to cast a non-LC column, triggering a LOGICAL_ERROR exception in debug builds. Fix by using only top-level column conversions (Const, Sparse, LowCardinality) instead of the recursive `convertToFullIfNeeded`, keeping the column structure consistent with the type's serialization. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97581&sha=320e7c9d8876b04a971bd26214b9ac0ab433c250&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 24, 2026
Algunenano
added a commit
to Algunenano/ClickHouse
that referenced
this pull request
Feb 24, 2026
…ke `Tuple` `convertToFullIfNeeded` (made recursive in ClickHouse#97493) strips `LowCardinality` from inner subcolumns of compound types (Tuple, Array, etc.) in `Set::insertFromColumns`, but `set_elements_types` in `Set::setHeader` only stripped top-level `LowCardinality`. This created a column/type mismatch: `ColumnVector<Int8>` in the column vs `LowCardinality(Int8)` in the type. When `KeyCondition::tryPrepareSetColumnsForIndex` unpacked the tuple to build index conditions for `IN` subqueries, `castColumn` tried to interpret the plain column as `ColumnLowCardinality`, causing a LOGICAL_ERROR exception in debug builds. Fix by using `recursiveRemoveLowCardinality` for `set_elements_types` in both `Set::setHeader` and the static `Set::getElementTypes`, matching what `convertToFullIfNeeded` does to columns. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97831&sha=6f56284303c16ecc5f5a437491c661d5019f2977&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avogar
added a commit
that referenced
this pull request
Feb 24, 2026
Backport #97493 to 26.1: Make convertToFullIfNeeded recursive for compound column types
Algunenano
pushed a commit
to Algunenano/ClickHouse
that referenced
this pull request
Feb 24, 2026
…IfNeeded-recursive Make convertToFullIfNeeded recursive for compound column types
Algunenano
pushed a commit
to Algunenano/ClickHouse
that referenced
this pull request
Feb 24, 2026
The `concat` function's `executeFormatImpl` called `convertToFullIfNeeded` which, after it was made recursive in ClickHouse#97493, strips `LowCardinality` from inside compound column types like `Variant`. However, the argument type is not updated to match, so `SerializationLowCardinality` tries to cast a non-LC column, triggering a LOGICAL_ERROR exception in debug builds. Fix by using only top-level column conversions (Const, Sparse, LowCardinality) instead of the recursive `convertToFullIfNeeded`, keeping the column structure consistent with the type's serialization. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97581&sha=320e7c9d8876b04a971bd26214b9ac0ab433c250&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
IColumn::convertToFullIfNeedednow recursively converts inner columns of compound types (ColumnTuple,ColumnArray,ColumnNullable,ColumnMap, etc.) usingforEachSubcolumnSet::appendSetElementsorMergeTreeIndexAggregatorSet::updateprocessed batches from different MergeTree parts with different sparse serialization profiles for inner tuple elementsCloses #97474
Closes #97335
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97431&sha=6fe0e8c44dd5c6a12583390b4f8fc45e226a3cb4&name_0=PR&name_1=Stateless%20tests%20%28arm_asan%2C%20azure%2C%20parallel%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix assertion failure (exception in debug/sanitizer builds) in
SetandMergeTreeIndexSetwhen processing columns with inner sparse subcolumns (e.g.,Tuplecolumns from MergeTree parts with different sparse serialization profiles).🤖 Generated with Claude Code