Fix premature chassert(analyzed_join.oneDisjunct()) for ASOF JOIN#106194
Open
groeneai wants to merge 1 commit into
Open
Fix premature chassert(analyzed_join.oneDisjunct()) for ASOF JOIN#106194groeneai wants to merge 1 commit into
chassert(analyzed_join.oneDisjunct()) for ASOF JOIN#106194groeneai wants to merge 1 commit into
Conversation
The AST fuzzer (`amd_debug`) surfaced a debug-build abort with stack `TreeRewriter::collectJoinedColumns -> abortOnFailedAssertion`, hash `STID 2508-3d70`, on queries shaped like `SELECT * FROM t0 ASOF LEFT JOIN t1 ON and((t0.y > t1.y))`. Root cause: `chassert(analyzed_join.oneDisjunct())` at `src/Interpreters/TreeRewriter.cpp:759` also asserts that the single clause is non-empty. For an `ASOF` JOIN whose `ON` expression is a pure inequality (no equality key), `CollectJoinOnKeysVisitor` records the `ASOF` keys into `data.asof_*_key` but does NOT populate `key_names_left` / `key_names_right`. The clause stays empty. In release builds the following `any_keys_empty` check throws `INVALID_JOIN_ON_EXPRESSION` cleanly; the assertion was harmless because `assert` was a no-op. After 445dafb converted `assert` to `chassert`, the assertion fires in debug builds before the proper error can be thrown. The shape produced by the fuzzer (`and(...)` around a single inequality) is incidental — the same failure reproduces for the simpler `ON t0.y > t1.y`. Fix: weaken to a count-only check (mirroring the OR branch at line 753). Empty clauses for non-`ASOF` cases are still caught by the existing `any_keys_empty` throw immediately below; ASOF clauses are populated later by `data.asofToJoinKeys`. Stack trace (debug build): 0. Common/Exception.cpp:60 DB::abortOnFailedAssertion 1. Interpreters/TreeRewriter.cpp:759 collectJoinedColumns 2. Interpreters/TreeRewriter.cpp:1494 TreeRewriter::analyzeSelect 3. Interpreters/InterpreterSelectQuery.cpp:821 InterpreterSelectQuery Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=13a9b8ea79c017e7e34c4b6065660398647e35f7&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_debug%29
Contributor
Author
|
Pre-PR validation gate (session
|
Contributor
Author
Contributor
|
Workflow [PR], commit [98619d6] Summary: ❌
AI ReviewSummaryThis PR weakens the old analyzer's single-disjunct assertion in Final VerdictStatus: ✅ Approve |
Contributor
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 4/4 (100.00%) | Lost baseline coverage: none · Uncovered code |
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.
The AST fuzzer (
amd_debug) reported a debug-build abort with stackTreeRewriter::collectJoinedColumns -> abortOnFailedAssertion,hash
STID 2508-3d70, on queries shaped like:chassert(analyzed_join.oneDisjunct())atTreeRewriter.cpp:759alsoasserts that the single clause is non-empty. For an
ASOFJOIN whoseONexpression is a pure inequality (no equality key),
CollectJoinOnKeysVisitorrecords theASOFkeys intodata.asof_*_keybut does NOT populate
key_names_left/key_names_right. The clause staysempty. In release builds the immediately-following
any_keys_emptycheckthrows
INVALID_JOIN_ON_EXPRESSIONcleanly; the assertion was harmlessbecause
assertwas a no-op. After commit445dafb5f098converted
asserttochassert, the assertion fires in debug buildsbefore the proper error can be thrown.
The shape produced by the fuzzer (
and(...)around a single inequality) isincidental — the same failure reproduces for the simpler
ON t0.y > t1.y.Fix: weaken to a count-only check, mirroring the OR branch immediately
above (line 753). Empty clauses for non-
ASOFcases are still caught bythe existing
any_keys_emptythrow immediately below;ASOFclauses arepopulated later by
data.asofToJoinKeys.Tested with
clickhouse local(debug build,enable_analyzer = 0):ON t0.y > t1.yandON and((t0.y > t1.y)).INVALID_JOIN_ON_EXPRESSIONcleanly; properASOFJOINs with an equality + inequality continue to work.
Report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=13a9b8ea79c017e7e34c4b6065660398647e35f7&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_debug%29
No related open issue found.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not for changelog:
chassertonly fires in debug / sanitizer builds; release behaviour is unchanged.Documentation entry for user-facing changes