Repository navigation
Fix LOGICAL_ERROR 'Trying to get name of not a column' in multiIf matcher inside table function argument - #106647
Conversation
…h matcher inside table function Closes: ClickHouse#43199 Closes: ClickHouse#97988 Closes: ClickHouse#100323 Related: ClickHouse#106172 The new-analyzer constant-folding helper for `multiIf` in `resolveFunction.cpp` held its condition through `auto & cond_node = multi_if_args[2 * pair];`. `resolveExpressionNode` rebinds its argument when the node is a matcher (`*`), which silently swapped the slot in `multi_if_args` for an empty `ListNode`. When a later argument throws `UNKNOWN_IDENTIFIER`, `resolveTableFunction` catches it (`QueryAnalyzer.cpp:4329-4351`) and skips analysis, but the original argument tree already carries the corrupted `ListNode` child. `table_function_node_typed.toAST()` re-emits `multiIf(ExpressionList(), ...)`, `parseArguments` accepts it, and `TableFunctionNumbers::evaluateArgument` calls `evaluateConstantExpression`, which raises a `LOGICAL_ERROR` from `IAST::appendColumnName` (`IAST.h:122`) when walking `ASTFunction`'s children. Snapshot `cond_node` into a local copy before `resolveExpressionNode` so matcher rebinding cannot leak back into the original slot. Mirrors the `is_special_function_if` pattern at `resolveFunction.cpp:485`. Reproducer (aborts master HEAD `378a25bb3b15`, returns clean `UNSUPPORTED_METHOD` with the fix): SELECT * FROM numbers(multiIf(*, number, 1), 2); CIDB shows 25+ unrelated PR sightings and 2 master hits in the last 30 days (BuzzHouse `amd_debug` 2026-06-01 sha `7ca836227b`, AST fuzzer `amd_debug` 2026-05-30 sha `d2e9760e19`) under runner test name "Logical error: Trying to get name of not a column: A (STID: 2310-*)". The "A" is a placeholder; the underlying message is "Trying to get name of not a column: ExpressionList". This is a tightened resubmit of ClickHouse#106172 with only the new-analyzer half; the bundled old-analyzer hunk in `InterpreterSelectQuery.cpp` and the `04303` test were dropped per the "old analyzer frozen except crashes" policy that closed ClickHouse#106172 on 2026-06-05. Reference: ClickHouse#100436 (comment) Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Pre-PR validation gate (per TASK.md Phase 4):
Session: cron:clickhouse-ci-task-worker:20260606-202800 |
|
cc @KochetovNicolai @novikd, could you review this? Tightened resubmit of #106172 with only the new-analyzer half: snapshot the multiIf condition into a local copy before resolveExpressionNode so matcher rebinding cannot corrupt the slot in multi_if_args. Old-analyzer hunk dropped per the policy that closed #106172. |
|
Workflow [PR], commit [4f6d3a1] Summary: ❌
AI ReviewSummaryThis PR fixes the new-analyzer Final VerdictStatus: ✅ Approve |
CI ledger — post-CI triage for HEAD
|
| Check | Test | Disposition |
|---|---|---|
CH Inc sync |
(downstream sync bot) | Infra / not part of praktika — sync PR has merge conflicts; not blocking and unrelated to this change. |
All 146 praktika checks pass (Style, Fast test, Builds, Stateless tests across all sanitizers + storage variants, Integration tests across all sanitizers, Stress tests, AST fuzzer, BuzzHouse, Performance Comparison, Compatibility, Install packages, SQLLogic, Mergeable Check, Finish Workflow). CIDB returns zero FAIL/ERROR rows for this PR in the last 24h.
Ready for review.
— groeneai (cron:our-pr-ci-monitor:20260607-033000)
…umbers Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 5/5 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
Overrode CI. |
a0b506e
Closes: #43199
Closes: #97988
Closes: #100323
Related: #106172
Related: #100436 (comment)
When a
multiIfargument inside a table-function call contains a matcher (*), the new-analyzer constant-folding helper held the condition throughauto & cond_node = multi_if_args[2 * pair];.resolveExpressionNoderebinds matchers in place, swappingmulti_if_args[0]for an emptyListNode. A subsequent argument throwingUNKNOWN_IDENTIFIERcausesresolveTableFunctionto skip analysis but the original argument tree already carries the corrupted child, sotoAST()emitsmultiIf(ExpressionList(), ...)andevaluateConstantExpressionraisesLOGICAL_ERRORfromIAST::appendColumnName.Snapshot
cond_nodeinto a local copy before resolving, mirroring theis_special_function_ifpattern atresolveFunction.cpp:485.Reproducer (aborts on master HEAD
378a25bb3b15, returns cleanUNSUPPORTED_METHODwith the fix):This is a tightened resubmit of #106172 with only the new-analyzer half; the old-analyzer hunk in
InterpreterSelectQuery.cppand04303test were dropped per the "old analyzer frozen except crashes" policy that closed #106172 on 2026-06-05.CIDB shows 25+ unrelated PR sightings and 2 master hits in the last 30 days (BuzzHouse
amd_debug2026-06-01, AST fuzzeramd_debug2026-05-30) under runner test name "Logical error: Trying to get name of not a column: A (STID: 2310-*)". The runner replaces format placeholders withA,B,C; the underlying message is "Trying to get name of not a column:ExpressionList".CI report context for the directive on #100436: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100436&sha=76d70c8c3f11a42854a7f3babb04d23e58fec931&name_0=PR&name_1=AST%20fuzzer%20%28amd_tsan%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a
LOGICAL_ERROR"Trying to get name of not a column:ExpressionList" raised by queries that pass an asterisk insidemultiIfto a table function argument, e.g.numbers(multiIf(*, ...), 2). The query now rejects the unresolvable matcher withUNSUPPORTED_METHOD.Documentation entry for user-facing changes
Version info
26.6.1.1016