Repository navigation
Regression test for #105650 isNotDistinctFrom String GROUP BY - #105675
alexey-milovidov merged 7 commits into
Conversation
`FunctionsNullSafeCmp::executeImpl` built an inner `FunctionComparison` and called `executable_func->execute(..., dry_run = false)` regardless of the outer call, so header-time partial evaluation (`ActionsDAG::updateHeader` -> `evaluatePartialResult`) materialised the inner comparator on the placeholder columns produced by `cloneResized(0)`. On a String GROUP BY key with `<=>`, that path reached `FunctionComparison::executeString` and tripped a `PODArray::operator[]` debug assertion in `ColumnString::getDataAt` (ClickHouse#105650). Override `executeImplDryRun` and split `executeImpl` into a thin public override and a private overload that takes `dry_run`, mirroring the pattern in `FunctionIn` and `ExecutableFunctionExpression`. The inner comparator now sees the same `dry_run` flag as the outer call. Adds a regression test for the exact fuzzer query plus a minimised form. Closes ClickHouse#105650
Pre-PR validation gate (session
|
|
Workflow [PR], commit [92b9451] Summary: ✅ AI ReviewSummaryThis PR is now test-only: it adds Final Verdict
|
Forwarding the outer `dry_run` flag to the inner `FunctionComparison` is not sufficient: `FunctionComparison` does not override `executeImplDryRun`, so the default in `IFunction::executeImplDryRun` falls back to `executeImpl`. With `String` placeholder columns produced by `cloneResized(0)` during `ActionsDAG::updateHeader` -> `evaluatePartialResult` this still trips the `ColumnString::getDataAt` `PODArray` assertion the fix was meant to avoid (issue ClickHouse#105650, bot review on PR ClickHouse#105675). Short-circuit at the top of the private `executeImpl` instead. The short-circuit is gated on `dry_run && input_rows_count == 0` so it only fires for header-time partial evaluation, which is the path that touches placeholders. The other `dry_run` consumer (`evaluateConstantExpression` via `evaluatePartialResult` with `input_rows_count = 1`) still goes through the regular comparator path because the arguments there are real constants, not placeholders. The 04274 regression test continues to pass; 03611, 02868 and 04010 (null-safe comparison tests that depend on constant folding via the `dry_run` path) also still pass.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 314afc2. Configure here.
Addresses Cursor Bugbot finding on PR ClickHouse#105675 (commit `314afc2d0068`). The previous fix-up commit added a zero-row short-circuit at the top of `FunctionsNullSafeCmp::executeImpl(args, type, rows, dry_run)`, which handles the `ActionsDAG::updateHeader` -> `evaluatePartialResult` path that constructs placeholder columns via `cloneResized(0)`. However, the inner `executable_func->execute()` call still hardcoded `/*dry_run=*/false`, silently dropping the forwarded flag for any `dry_run && input_rows_count > 0` path (e.g. the `evaluateConstantExpression` constant-folding path). `FunctionComparison` does not override `executeImplDryRun`, so the default in `IFunction::executeImplDryRun` falls back to `executeImpl`. Forwarding `dry_run` to the inner comparator is therefore a no-op in terms of current behaviour, but it keeps the dry-run signal flowing end-to-end (matching the pattern in `ExecutableFunctionExpression` and the convention used by `FunctionIn`) and avoids a latent foot-gun if `FunctionComparison` ever gains a real dry-run path. Tests: - 50/50 randomized runs of `04274_105650_isNotDistinctFrom_string_group_by` PASS - 10/10 randomized runs of `03611_null_safe_comparsion`, `02868_operator_is_not_distinct_from_priority`, `04010_null_safe_cmp_dynamic_const` PASS - Constant-folding through `dry_run` still produces correct results because the inner dispatch lands at the same `executeImpl` either way.
Trim the rationale comments inside `FunctionsNullSafeCmp::executeImpl` and the regression test header to keep them compact; the full story lives in the PR description and in issue ClickHouse#105650. The behaviour is unchanged; only comments were touched.
|
Re-categorised this PR as Improvement instead of Bug Fix, and pushed Rationale for the recategorisation:
|
Algunenano
left a comment
There was a problem hiding this comment.
@groeneai I don't understand the point of these code changes.
The only thing that makes sense is forwarding dry_run on the case that, maybe, in a distant future, the called function changes behaviour because of it, but to be honest seeing how little this flag is used in the code base (3 real use cases) we would be better off not adding more of them unless it's strictly necessary.
Also, in the future please avoid making code changes that you can back with test, queries or reports. If somebody asks you to investigate a report and you can't reproduce it, say so and avoid making changes. Ask for more logs, coredumps, or whatever extra information you need to investigate further. In case you still cannot reproduce it you can simply open a PR with the test, showing it does not reproduce in HEAD, and closing the issue.
Per @Algunenano review on PR ClickHouse#105675: dry_run has only 3 real use cases in the codebase, and the original ClickHouse#105650 fuzzer finding is already masked on master by ClickHouse#100226 (ColumnConst node invariant + dry_run propagation in lambda execution). Adding more dry_run plumbing without a current behavioural bug to back it is unjustified. Keep the regression test (04274_105650_isNotDistinctFrom_string_group_by) so the fuzzer query and a minimised isNotDistinctFrom + WITH ROLLUP form remain exercised on master HEAD.
|
Thanks for the review. I dropped the The regression test ( Behavioral correction noted and memorized: when a report does not reproduce, I will say so and ask for more info (logs, coredumps, exact commit/query) instead of making speculative code changes. If reproduction is still impossible, I will open a test-only PR showing the bug does not reproduce on HEAD and close the issue. |
Per @Algunenano on PR ClickHouse#105675: 1. Use `FORMAT Null` instead of a `SELECT count() FROM (...)` wrapper around the original fuzzer query, so the test exercises the exact same query the fuzzer found. 2. Rename the table from `_s1_105650` to `t1`, dropping the leading underscore. Updated the reference file to drop the now-absent count row. ClickHouse#105675
|
Both addressed in 17a0599:
Reference file updated accordingly (one fewer row). |
|
@groeneai It seems that the CI is able to reproduce an issue with the new test under MSAN. Please extract a reproducer (likely you'll need to find the exact settings to use), then find the cause, which change introduced it (if recent) and the fix. |
…rom form The original fuzzer query uses groupArrayMovingAvgStateDistinctOrDefaultDistinctOrNull with WITH ROLLUP, which triggers a separate pre-existing trunk bug (ClickHouse#105740 / ClickHouse#105742) in ColumnAggregateFunction::convertToValues under MSan. The fix for that bug lives in ClickHouse#105749 (currently open). The minimised isNotDistinctFrom form alone still exercises the partial-evaluation path that ClickHouse#105650 was concerned about and produces the same .reference output. Locally verified 5/5 passes via clickhouse-test with randomized settings.
|
Reproducer extracted, cause identified, fix is in flight. Reproducer. The trigger is the original fuzzer query already in the test ( and the second sanitizer track ( Cause. Pre-existing trunk bug, not introduced by this PR. Which change introduced it. Not recent. The aliasing has been there as long as State combinators have used The fix. #105749 (currently open). It switches Action on this PR. I pushed 92b9451 dropping just the fuzzer query from |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 375 line(s), 32 function(s) across 114 file(s) · Details Top files
|

Regression test for #105650 (fuzzer finding on debug aarch64):
PODArray::operator[]assertion inColumnString::getDataAtwhen header-time partial evaluation propagates zero-row placeholder columns through<=>(isNotDistinctFrom) over aStringGROUP BYkey withWITH ROLLUP.The symptom is already masked on current master by #100226 (
ColumnConstnode invariant + dry_run propagation through lambda execution). This PR is the test-only follow-up per @Algunenano's review on the original commit history: keep the regression check, drop the unmotivateddry_runplumbing.The new stateless test
04274_105650_isNotDistinctFrom_string_group_byruns the original fuzzer query plus a minimised form and passes on master HEAD.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not required (test-only).
Documentation entry for user-facing changes