Skip to content

Fix exception in concat with Variant containing LowCardinality#97654

Merged
alexey-milovidov merged 4 commits intomasterfrom
fix-concat-variant-low-cardinality
Feb 23, 2026
Merged

Fix exception in concat with Variant containing LowCardinality#97654
alexey-milovidov merged 4 commits intomasterfrom
fix-concat-variant-low-cardinality

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

Summary

  • Fix LOGICAL_ERROR exception (Bad cast from type DB::ColumnVector<char8_t> to DB::ColumnLowCardinality) in the concat function when an argument is an array containing a Variant type with LowCardinality inside (e.g., concat('a', [(1, 2), toLowCardinality(3)]))
  • The issue was introduced by Make convertToFullIfNeeded recursive for compound column types #97493 which made convertToFullIfNeeded recursive — it now strips LowCardinality from inside compound column types like ColumnVariant, but the argument type is not updated to match, causing a type/column mismatch during serialization
  • Fix by using only top-level column conversions (Const, Sparse, LowCardinality) instead of the recursive convertToFullIfNeeded

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97581&sha=320e7c9d8876b04a971bd26214b9ac0ab433c250&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29

Test plan

  • Added test 03987_concat_variant_low_cardinality with reproducer queries
  • Verified fix passes in debug build (previously crashed with SIGABRT)
  • Verified existing concat functionality is not affected

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC) or LOGICAL_ERROR

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix LOGICAL_ERROR exception in concat when an argument contains a Variant type with LowCardinality inside.

🤖 Generated with Claude Code

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>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 22, 2026

Workflow [PR], commit [94356bc]

Summary:

@clickhouse-gh clickhouse-gh bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Feb 22, 2026
@nihalzp nihalzp self-assigned this Feb 23, 2026
@alexey-milovidov alexey-milovidov added this pull request to the merge queue Feb 23, 2026
Merged via the queue into master with commit 6efaa79 Feb 23, 2026
148 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-concat-variant-low-cardinality branch February 23, 2026 17:58
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 23, 2026
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Feb 23, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Feb 23, 2026
Cherry pick #97654 to 25.3: Fix exception in concat with Variant containing LowCardinality
robot-clickhouse added a commit that referenced this pull request Feb 23, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Feb 23, 2026
Cherry pick #97654 to 25.8: Fix exception in concat with Variant containing LowCardinality
robot-clickhouse added a commit that referenced this pull request Feb 23, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Feb 23, 2026
Cherry pick #97654 to 25.11: Fix exception in concat with Variant containing LowCardinality
robot-clickhouse added a commit that referenced this pull request Feb 23, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Feb 23, 2026
Cherry pick #97654 to 25.12: Fix exception in concat with Variant containing LowCardinality
robot-clickhouse added a commit that referenced this pull request Feb 23, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Feb 23, 2026
Cherry pick #97654 to 26.1: Fix exception in concat with Variant containing LowCardinality
robot-clickhouse added a commit that referenced this pull request Feb 23, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Feb 23, 2026
clickhouse-gh bot added a commit that referenced this pull request Feb 23, 2026
Backport #97654 to 26.1: Fix exception in concat with Variant containing LowCardinality
Algunenano added a commit to Algunenano/ClickHouse that referenced this pull request Feb 24, 2026
…ntaining `LowCardinality`

Same bug as fixed for `concat` in ClickHouse#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>
Algunenano pushed a commit to Algunenano/ClickHouse that referenced this pull request Feb 24, 2026
…t-low-cardinality

Fix exception in concat with Variant containing LowCardinality
@Algunenano Algunenano removed the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Feb 25, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

6 participants