Repository navigation
Cherry pick #111930 to 26.7: Fix Block structure mismatch when the split filter column name clashes with an input - #114292
Merged
robot-ch-test-poll4 merged 5 commits intoAug 11, 2026
Conversation
…an input The AST fuzzer hit a logical error during query plan optimization: Block structure mismatch in IntersectOrExceptStep stream: different number of columns: ... __split_filter Nullable(Nothing) ... / (sibling has 3 cols) trySplitFilter hand-rolled a workaround for the case where the filter column name is also an input name. It called splitActionsForFilter without avoid_duplicate_inputs, so the first DAG half ended up with two same-named outputs (the pass-through input and the promoted computed filter node), and then renamed the first match to the literal "__split_filter". Given the append order, that first match is the pass-through, not the computed node. The rename also reused remove_filter, a flag computed for the ORIGINAL name in the OTHER half, as the removal flag for the synthetic name; when it is false the inner FilterStep keeps the column. The outer ExpressionStep cannot drop it either, because split.second's inputs still carry the original name and ActionsDAG::updateHeader passes through unmatched header columns. So __split_filter reached the branch output header, and the parent-header refresh loop in optimizeTreeFirstPass pushed the wider header into IntersectOrExceptStep::checkHeaders against the sibling branch. ActionsDAG::split already solves this collision properly when avoid_duplicate_inputs is set: it renames the promoted computed node in the first half and repairs the second half by adding an input under the new name while rewriting the old node into an ALIAS onto it, so second-half references to the original name still resolve. Delete the hand-rolled workaround, set both flags inside splitActionsForFilter (it has a single caller, so its signature and ActionsDAG.h are untouched), and read the filter name from split_nodes_mapping, the same idiom as splitSingleAndFilter in FilterStep.cpp. The rename only fires on a genuine collision, so plans without one are unchanged. __split_filter no longer exists in the source. The leak also aborts with UNION ALL and EXCEPT, since they share the same checkHeaders shape, so the test covers all three. It asserts the branch output header column count rather than the absence of a literal name, so a stray internal column would be caught under any name, and it asserts the '[split]' step marker so the file cannot pass without the optimization running. A second query keeps the clashing name live downstream and pins its result values, which proves the renamed column still resolves in the second half. Found by AST fuzzer (amd_msan) on an unrelated PR, STID 0993-315b. Same family as #108142 and #108210. Co-Authored-By: Claude Opus 4.8 <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]>
…filter-header-leak
…filter-header-leak
…ader-leak Fix Block structure mismatch when the split filter column name clashes with an input
Resolve conflict in src/Processors/QueryPlan/Optimizations/splitFilter.cpp by taking the change from #111930: the old filter_name_clashes_with_input workaround is replaced by the split_nodes_mapping-based rename. Co-Authored-By: Claude Fable 5 <[email protected]>
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.
Original pull-request #111930
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-picklocally.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:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job