Repository navigation
Position based unused column removal - #100586
Conversation
|
Workflow [PR], commit [7d5e40d] AI ReviewSummaryThis PR switches unused-column removal from name-based to position-based behavior across query-plan steps ( Final Verdict
|
… the inputs of the join
Technically this shouldn't be a problem, because joins currently must have inputs from both sides, but technically this is the correct check.
1fa4727 to
4c9e414
Compare
|
@antaljanosbenjamin Created #105521 specifically for the issue I'm seeing. Thank you! |
| Block new_input_header{}; | ||
| /// Build the set of required input header positions: DAG inputs that survived pruning + required pass-throughs. | ||
| auto matched_positions = actions_dag.matchInputPositionsToHeader(*input_header).matched; | ||
| std::set<size_t> required_input_positions(matched_positions.begin(), matched_positions.end()); |
There was a problem hiding this comment.
ActionsDAG::matchInputNodesToHeader() is building a map absl::flat_hash_map<std::string_view, inline_vector> input_positions and seems to do a name based lookup. Do we risk getting a mixup here when there's two columns in input_header with the same name?
There was a problem hiding this comment.
We shouldn't: we collect the columns with same name into a vector and pop one of them on a match. Because we put the input columns into the vector in reversed order (size_t pos = input_nodes.size(); pos != 0; pos--), we match the first input header for the first input with that name, the second column to the second input etc.
LLVM Coverage Report
Changed lines: 91.47% (472/516) | lost baseline coverage: 28 line(s) · Uncovered code |
|
Hi @antaljanosbenjamin @cv4g — a couple of suggestions to make this PR easier for reviewers and the changelog reader. Description (currently
Ignore this if the current title/body is intentional. |
`ReadSettings::http_max_tries` and friends moved into the nested `http_settings` struct on master (PR #100586's IO refactor). Update the four call sites that build HTTP read settings for the stateless worker client.
Per @antaljanosbenjamin's suggestion on PR ClickHouse#106104, prevent the same column from being added twice at the source instead of relaxing the downstream validator. The previous commit relaxed `ReadFromMergeTree::removeUnusedColumns` to tolerate same-pointer duplicates in the filter DAG outputs. That worked but kept the duplicate around in every downstream consumer. This change eliminates the duplicate at the producers: * `Planner/Utils.cpp::buildFilterInfo` (analyzer path) -- when the filter expression is one of the inputs (bare-column case), skip the redundant passthrough push and set `remove_filter_column = false` so `FilterTransform` does not erase the column we want to keep. * `Interpreters/InterpreterSelectQuery.cpp::generateFilterActions` (legacy path) -- same logic: detect the bare-input filter result, skip its passthrough push, and set `do_remove_column = false`. * `Interpreters/ExpressionAnalyzer.cpp` -- drop the unconditional `row_policy_info->do_remove_column = true;` override that masked the producer-side decision. The producer now sets the correct value for both bare-column and computed-column policies. * `Processors/QueryPlan/ReadFromMergeTree.cpp` -- restore the strict name-based duplicate validator. Producer-side dedup makes same-pointer duplicates impossible in well-formed DAGs, so the original check from PR ClickHouse#100586 is safe again. Regression test improvements (per bot review): the data set now includes a row with `c0 = 0` and explicit `count()` / `countIf` queries. The test now catches both (a) the `LOGICAL_ERROR` reappearing AND (b) the policy silently not being applied -- the second mode would let the falsy row through, which a `count() == 3` assertion catches. The Cause 2 fix in `projectionsCommon.cpp::findInOutputs` (turn `ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER` into a graceful `nullptr` for non-`UInt8` filters) is unchanged and independent of the dedup approach. PR review: ClickHouse#106104 Issue: ClickHouse#106099
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Identify columns by position (instead of by name) when removing unused columns in the query plan. This enables unused-column removal when duplicated column names are present.
Documentation entry for user-facing changes
Version info
26.6.1.195