Fix exception in KILL QUERY when columns are const#99881
Fix exception in KILL QUERY when columns are const#99881alexey-milovidov merged 5 commits intomasterfrom
Conversation
The `getSelectResult` method in `InterpreterKillQueryQuery` executes a SELECT query against system tables and returns a block. The callers use `typeid_cast` to cast columns to concrete types like `ColumnString`. However, the query optimizer can produce `ColumnConst` wrappers, causing the cast to fail with "Bad cast from type A to B". Fix by materializing const columns in the returned block. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98138&sha=a349e29ce98d34354439478bec564adb7d5b66c9&name_0=PR&name_1=Stress%20test%20%28amd_msan%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Test exercises the KILL QUERY, KILL MUTATION, and KILL TRANSACTION code paths with TEST mode to verify that `typeid_cast` to concrete column types does not fail. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [b5bb249] Summary: ✅ AI ReviewSummaryThis PR fixes a real exception path in ClickHouse Rules
Final Verdict
|
The `system.transactions` table exists in CI builds, so the query succeeds rather than failing with UNKNOWN_TABLE. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
A question - why were columns const? |
|
|
The table `system.transactions` only exists when experimental transactions are enabled, causing UNKNOWN_TABLE on most CI configs. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 100.00% (4/4, 1 noise lines excluded) |
The
getSelectResultmethod inInterpreterKillQueryQueryexecutes a SELECT against system tables and returns a block. Callers usetypeid_castto cast columns to concrete types likeColumnString. However, the query pipeline can produceColumnConstwrappers, causing the cast to fail with "Bad cast from type X to Y".Fix by calling
materializeBlockInplaceon the returned block.Found in stress test with AST fuzzer: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98138&sha=a349e29ce98d34354439478bec564adb7d5b66c9&name_0=PR&name_1=Stress%20test%20%28amd_msan%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix exception "Bad cast from type X to Y" in
KILL QUERYwhen the internal query against system tables returns columns wrapped inColumnConst.Documentation entry for user-facing changes