Skip to content

Cherry pick #98291 to 25.8: Fix bad cast exception when filtering _table virtual column in merge table function - #105627

Merged
robot-ch-test-poll2 merged 7 commits into
backport/25.8/98291from
cherrypick/25.8/98291
May 22, 2026
Merged

robot-ch-test-poll2 merged 7 commits into
backport/25.8/98291from
cherrypick/25.8/98291

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

Original pull-request #98291

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 7 commits February 28, 2026 02:41
…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]>
…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]>
…umn-bad-cast

Fix bad cast exception when filtering `_table` virtual column in `merge` table function
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels May 22, 2026
@robot-ch-test-poll2
robot-ch-test-poll2 merged commit 9edfeee into backport/25.8/98291 May 22, 2026
@robot-ch-test-poll2
robot-ch-test-poll2 deleted the cherrypick/25.8/98291 branch May 22, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants