Repository navigation
Fix bad cast exception when filtering _table virtual column in merge table function - #98291
Merged
Merged
Conversation
…ge()` table function The `_database` and `_table` virtual columns in `StorageMerge` are defined as `LowCardinality(String)`, but `getSelectedTables` constructed the filter sample block and columns using plain `String` type. When the query analyzer generated a filter expression expecting `LowCardinality(String)` (e.g. with tuple IN), executing that filter against plain `String` columns caused a `LOGICAL_ERROR: Bad cast from type DB::ColumnString to DB::ColumnLowCardinality`. Fix by using `LowCardinality(String)` in the sample block and filter lambda, matching the actual virtual column definitions. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98251&sha=73e60a55c201e3724f9c35da27ac9c7a182e99d8&name_0=PR&name_1=AST%20fuzzer%20%28amd_ubsan%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
alexey-milovidov
force-pushed
the
fix-merge-table-virtual-column-bad-cast
branch
from
February 28, 2026 02:41
ac4d053 to
abe0697
Compare
…ple IN query
The query `('test_local_1', 'test_local_2') IN (_table)` is semantically
invalid (checking if a tuple is in a string column). Previously it caused
a `LOGICAL_ERROR` (bad cast), now it correctly returns a user-facing error.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
alexey-milovidov
added a commit
that referenced
this pull request
Mar 1, 2026
…umn-bad-cast Fix bad cast exception when filtering `_table` virtual column in `merge` table function
3 tasks done
|
Backport labels have been automatically added based on https://github.com/ClickHouse/clickhouse-core-incidents/issues/667 Labels added:
These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels. |
robot-ch-test-poll2
added a commit
that referenced
this pull request
May 22, 2026
Cherry pick #98291 to 25.8: Fix bad cast exception when filtering `_table` virtual column in `merge` table function
robot-clickhouse
added a commit
that referenced
this pull request
May 22, 2026
…e` virtual column in `merge` table function
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.
Linked issues
The
_databaseand_tablevirtual columns inStorageMergeare defined asLowCardinality(String), butgetSelectedTablesconstructed the filter sample block and columns using plainStringtype. When the query analyzer generated a filter expression expectingLowCardinality(String)(e.g. with tuple IN), executing that filter against plainStringcolumns caused aLOGICAL_ERROR: Bad cast from type DB::ColumnString to DB::ColumnLowCardinality.Fix by using
LowCardinality(String)in the sample block and filter lambda, matching the actual virtual column definitions.https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98251&sha=73e60a55c201e3724f9c35da27ac9c7a182e99d8&name_0=PR&name_1=AST%20fuzzer%20%28amd_ubsan%29
#98251
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix bad cast exception when filtering
_tablevirtual column inmergetable function.Version info
26.3.1.179