Cherry pick #97831 to 25.12: Fix LOGICAL_ERROR exceptions from recursive convertToFullIfNeeded with LowCardinality inside compound types#97980
Merged
robot-ch-test-poll merged 7 commits intobackport/25.12/97831from Feb 25, 2026
Conversation
…ntaining `LowCardinality` Same bug as fixed for `concat` in #97654: `convertToFullIfNeeded` recursively strips `LowCardinality` from inside compound column types like `Variant`, but 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`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ke `Tuple` `convertToFullIfNeeded` (made recursive in #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>
…variant Regression test for #97847: `Dynamic` column with `LowCardinality` variant and `enable_join_runtime_filters` caused LOGICAL_ERROR "Bad cast from type DB::ColumnVector<int> to DB::ColumnLowCardinality" because `Set` stored columns with inner `LowCardinality` stripped but `set_elements_types` still contained it inside the `Dynamic` type. Already fixed by the previous commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…al corruption `convertToFullIfNeeded` recursively strips `LowCardinality` from subcolumns, including variant columns inside `ColumnDynamic`. But it cannot update `ColumnDynamic::variant_info` type metadata, creating a mismatch: variant columns have LC stripped from data while `variant_info` still references LC types. This caused LOGICAL_ERROR in `Set::appendSetElements` when `ColumnDynamic::insertRangeFrom` tried to serialize values using LC serialization against non-LC column data. Fix: override `convertToFullIfNeeded` in `ColumnDynamic` to return itself without recursing into subcolumns. Dynamic is a self-contained typed container that manages its own variant types. Also add `max_threads=1` to the test for issue #97847 to reliably trigger the runtime filter code path that exercises this bug. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…/type mismatches Same issue as `ColumnDynamic`: `convertToFullIfNeeded` recursively strips `LowCardinality` from `ColumnVariant`'s internal variant sub-columns, but cannot update the corresponding `DataTypeVariant` (which sorts variants by name). This creates column/type position mismatches that cause LOGICAL_ERROR in `KeyCondition::tryPrepareSetColumnsForIndex` when casting set elements for index conditions. Fix: override `convertToFullIfNeeded` in `ColumnVariant` to return itself without recursing into sub-columns, matching the approach for `ColumnDynamic`. Closes #97854 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ormat-variant-low-cardinality Fix LOGICAL_ERROR exceptions from recursive `convertToFullIfNeeded` with `LowCardinality` inside compound types
0a562ce
into
backport/25.12/97831
137 of 140 checks passed
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.
Original pull-request #97831
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job