Repository navigation
Conversation
…ist`" Two unrelated call sites raise this assertion when they call `IAST::getColumnName` on an `ASTExpressionList`. Both sites have appeared in the AST fuzzer family (issues ClickHouse#43199, ClickHouse#97988, ClickHouse#100323; STIDs 2310-3e66 and 2310-3791). 1. `resolveFunction.cpp`: the `multiIf` constant-folding helper held its condition through `auto & cond_node = multi_if_args[2 * pair];`. `resolveExpressionNode` rebinds its argument when the node is a matcher (`*`), so the reference silently swapped the slot in `multi_if_args` for an empty `ListNode`. A later argument throwing `UNKNOWN_IDENTIFIER` then left the corrupted tree behind, which `toAST` re-emitted as `multiIf(ExpressionList(), ...)`. The helper now snapshots `cond_node` into a local copy, matching the existing `is_special_function_if` pattern. 2. `InterpreterSelectQuery.cpp::executeAggregation`: the `force_aggregation_in_order` branch called `getSortDescriptionFromGroupBy` without the `!useGroupingSetKey()` guard that the `optimize_aggregation_in_order` branch already has. With `GROUPING SETS` each set is an `ASTExpressionList`, so `getColumnName` aborts. Added the missing guard. Regression tests: * `04303_grouping_sets_force_aggregation_in_order.sql`: GROUPING SETS with `force_aggregation_in_order` under the old analyzer, plus the ALTER UPDATE shape from issue ClickHouse#97988 which routes through `replaceNonDeterministicToScalars`. * `04304_multi_if_asterisk_table_function.sql`: the fuzzer query `numbers(multiIf(*, moduloOrZero(number, NULL), 'a'), 2)` plus narrower variants for the matcher rejection and the unaffected constant-fold path.
|
Pre-PR validation gate (per TASK.md Phase 4): a) Deterministic repro? Yes. Each fix has a query that crashes a debug build at master HEAD
b) Root cause explained? Yes. STID 2310-3791: c) Fix matches root cause? Yes. Snapshot the multiIf condition into a local copy (mirrors the existing d) Test intent preserved? New tests added? Yes. e) Both directions demonstrated? Yes. With each fix temporarily reverted the corresponding regression test query aborts with exit 134 (SIGABRT); both fixes restored both queries return a clean error / correct output. f) Fix is general? I checked the other Session: |
|
cc @novikd @KochetovNicolai for review — touches comp-query-analyzer ( multiIf handling) and comp-query-execution (). |
|
cc @novikd @KochetovNicolai for review. Touches comp-query-analyzer (Analyzer/Resolve/resolveFunction.cpp multiIf handling) and comp-query-execution (Interpreters/InterpreterSelectQuery.cpp executeAggregation). |
|
Workflow [PR], commit [6699e02] Summary: ❌
AI ReviewSummaryThis PR fixes two Missing context / blind spots
Final VerdictStatus: ✅ Approve |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 9/9 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
@groeneai check the test failures |
The C++ fix that closes the original LOGICAL_ERROR ("Trying to get name of
not a column: `ExpressionList`") lives in the new analyzer's `resolveFunction`
(it snapshots the `multiIf` condition into a local copy before
`resolveExpressionNode`). Under the old analyzer, the same fuzzer queries reach
a different error path and return `UNKNOWN_IDENTIFIER` (47) instead of
`UNSUPPORTED_METHOD` (1), so the test failed in the
`amd_llvm_coverage, old analyzer, s3 storage, DatabaseReplicated, WasmEdge`
variant on 778a2da.
Pin `SET enable_analyzer = 1` at the top of 04304 so the regression test
exercises the path the fix actually changed. 04303 already pins the analyzer
explicitly per query, so no behaviour change there.
Also drop the long block-comments at the top of both files: the explanation
belongs in the commit message and PR description, not in the test source
(per @azat's directive on PR ClickHouse#106261).
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106172&sha=778a2daac011ae48ed5c59773d688ba2f09431e6&name_0=PR
PR: ClickHouse#106172
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@PedroTadim Triage of the four failing CI checks on
1. Stateless old-analyzer failure (PR-caused, fixed)The C++ fix for STID 2310-3791 lives in the new analyzer's
The variant name even includes While there I also stripped the long block-comments from both 04303 and 04304 — explanation belongs in the commit message and PR description, not in the test source (per @ azat's directive on PR #106261). 2.
|
|
@PedroTadim CI fully finished on
143 pass / 4 fail / 0 pending / 20 skipping; the 4 fails are the single infra root + 3 rollups. No PR-caused failures, no new flaky tests to track. |
novikd
left a comment
There was a problem hiding this comment.
This PR includes changes across different Analyzers, which correspond to different closed GH issues.
One with the new analyzer: test does not produce an error, and code changes do not make sense.
One with the old analyzer: test produces LOGICAL_ERROR -- no crash.
I think we should close this PR because we do not change old analyzer (except crashses) and mutations now use new analyzer.
|
|
||
| -- A multiIf whose condition is a real expression must keep working. | ||
| SELECT count() FROM numbers(multiIf(1, 5, 10), 1); | ||
| SELECT count() FROM numbers(multiIf(0, 5, 10), 1); |
There was a problem hiding this comment.
This test does not produce any error on the master.
| /// Skip on grouping sets: `getSortDescriptionFromGroupBy` calls `getColumnName` on | ||
| /// `GROUPING SETS` children which are `ASTExpressionList` and raise `LOGICAL_ERROR`. | ||
| /// Mirrors the guard on the `optimize_aggregation_in_order` branch above. | ||
| if (!group_by_info && settings[Setting::force_aggregation_in_order] && !query_analyzer->useGroupingSetKey()) |
There was a problem hiding this comment.
src/Interpreters/InterpreterSelectQuery.cpp should not be modified.
| /// Snapshot the condition; `resolveExpressionNode` rebinds a matcher (`*`) | ||
| /// argument to an empty `ListNode`, which would corrupt the slot. Mirrors | ||
| /// the `is_special_function_if` pattern above. | ||
| QueryTreeNodePtr cond_node = multi_if_args[2 * pair]; |
There was a problem hiding this comment.
This change makes no sense. No point in keeping a reference to the MatcherNode because it is:
- Unresolved
- Can not be constant folded
|
Thanks for the review. Acknowledging the policy reading. The PR bundled two fixes against different analyzers:
Session: cron:clickhouse-ci-task-worker:20260605-163200 |
…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]>
Two unrelated call sites raise this assertion when they call
IAST::getColumnNameon anASTExpressionList. Both surface in the AST fuzzer family (issues #43199, #97988, #100323; STIDs 2310-3e66 and 2310-3791). One is reachable fromnumbers(multiIf(*, ...), N)style queries; the other fromforce_aggregation_in_order=1plusGROUPING SETSunder the old analyzer.Root causes
STID 2310-3791 —
multiIfslot rebinding inresolveFunction.cppThe
multiIfconstant-folding helper held its condition throughauto & cond_node = multi_if_args[2 * pair];.resolveExpressionNoderebinds its argument when the node is a matcher (*), so the reference silently swapped the slot inmulti_if_argsfor an emptyListNode. A later argument throwingUNKNOWN_IDENTIFIERthen left the corrupted tree behind, whichtoASTre-emitted asmultiIf(ExpressionList(), ...). Snapshottingcond_nodeinto a local copy (matching theis_special_function_ifpattern) prevents the rebinding from leaking into the original slot.STID 2310-3e66 —
getSortDescriptionFromGroupByandGROUPING SETSinInterpreterSelectQuery.cpp::executeAggregationThe
force_aggregation_in_orderbranch calledgetSortDescriptionFromGroupBywithout the!useGroupingSetKey()guard that theoptimize_aggregation_in_orderbranch already has. WithGROUPING SETSeach set is anASTExpressionList, sogetColumnNameaborts. Adding the missing guard fixes it.Regression tests
04303_grouping_sets_force_aggregation_in_order.sql:GROUPING SETSwithforce_aggregation_in_orderunder the old analyzer, plus theALTER UPDATEshape from issue Logical error: Trying to get name of not a column: A (STID: 2310-3e66) #97988 which routes the inner SELECT throughreplaceNonDeterministicToScalars.04304_multi_if_asterisk_table_function.sql: the fuzzer querynumbers(multiIf(*, moduloOrZero(number, NULL), 'a'), 2)plus narrower variants to confirm the matcher rejection and the unaffected constant-fold path.Both tests crash debug builds at HEAD without the fix and pass with it.
Closes #43199
Closes #97988
Closes #100323
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 use an asterisk insidemultiIfarguments to a table function (e.g.numbers(multiIf(*, ...), 2)) and bySELECT ... GROUP BY GROUPING SETS (...)withforce_aggregation_in_order = 1under the old analyzer.Documentation entry for user-facing changes