Repository navigation
Fix duplicate columns in TableJoin::setUsedColumns causing exception in HashJoin::getNonJoinedBlocks - #100018
Merged
alexey-milovidov merged 3 commits intoMar 23, 2026
Conversation
…n in `HashJoin::getNonJoinedBlocks` `ActionsDAG::getRequiredColumnsNames` can return duplicate column names when the DAG has multiple input nodes with the same name. When these duplicates are passed to `TableJoin::setUsedColumns`, the same column gets pushed to `result_columns_from_left_table` multiple times. This causes a column count mismatch in `HashJoin::getNonJoinedBlocks` where the assertion expects the arithmetic sum of left + right_keys + right_added columns to equal `result_sample_block` columns (which are deduplicated). This is a follow-up to #98286 which fixed the same error via a different code path (`PlannerJoinTree`), but did not cover the `JoinStepLogical` path. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99936&sha=494ca1e7a6070de924219397dd6a93afb0c714a0&name_0=PR&name_1=AST%20fuzzer%20%28amd_msan%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [08d5d10] Summary: ✅ AI ReviewSummaryThis PR fixes two real issues: duplicate required column names in ClickHouse Rules
Final Verdict
|
1 task
…the input The previous fix unconditionally deduplicated all column names, which broke queries with legitimate duplicate columns (e.g., `SELECT number, number FROM numbers(5)` in a FULL JOIN). Instead, cap the number of times each column is added to `result_columns_from_left_table` / `columns_added_by_join` to the number of times it appears in the respective input column list. This fixes the Merge table case (where `ActionsDAG::getRequiredColumnsNames` returns spurious duplicates) while preserving correct behavior for queries that intentionally select duplicate columns. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…yQuery` `processCancel` writes `state.stop_read_return_partial_result` under `callback_mutex` (when called from a pipeline executor thread via `receiveClusterFunctionReadTaskResponse`), but `processOrdinaryQuery` reads it at line 1441 outside the lock. Read the value into a local variable under the existing `callback_mutex` lock to eliminate the race. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100018&sha=7c5081d08457af33ca97d7e5d51854ac8cd55c0f&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20s3%20storage%2C%20parallel%2C%201%2F2%29 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 100.00% (45/45, 0 noise lines excluded) |
alexey-milovidov
enabled auto-merge
March 23, 2026 20:26
alexey-milovidov
disabled auto-merge
March 23, 2026 20:26
alexey-milovidov
deleted the
fix-duplicate-columns-in-join-getNonJoinedBlocks
branch
March 23, 2026 20:26
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.
ActionsDAG::getRequiredColumnsNamescan return duplicate column names when the DAG has multiple input nodes with the same name. When these duplicates are passed toTableJoin::setUsedColumns(fromJoinStepLogical.cpp), the same column gets pushed toresult_columns_from_left_tablemultiple times. This causes a column count mismatch inHashJoin::getNonJoinedBlockswhere the assertion expects the arithmetic sum of left + right_keys + right_added columns to equalresult_sample_blockcolumns (which are deduplicated).This is a follow-up to #98286 which fixed the same error via a different code path (
PlannerJoinTree/buildJoinQueryPlan) but didn't cover theJoinStepLogicalpath.Found by AST fuzzer: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=99936&sha=494ca1e7a6070de924219397dd6a93afb0c714a0&name_0=PR&name_1=AST%20fuzzer%20%28amd_msan%29
#99936
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix logical error exception
Unexpected number of columns in result sample blockinHashJoin::getNonJoinedBlockswhen duplicate column names appear in the join's required columns list.Documentation entry for user-facing changes
🤖 Generated with Claude Code
Version info
26.4.1.164