Skip to content

Backport #123829 to 26.8: Do not read a JOIN input that cannot contribute under a WHERE no row passes - #124242

Merged
clickhouse-gh[bot] merged 3 commits into
26.8from
backport/26.8/123829
Oct 7, 2026
Merged

clickhouse-gh[bot] merged 3 commits into
26.8from
backport/26.8/123829

Conversation

@robot-ch-test-poll

@robot-ch-test-poll robot-ch-test-poll commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #123829
Cherry-pick pull-request #124218

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.8.20.12

@robot-ch-test-poll robot-ch-test-poll added the pr-backport Changes, backported to release branch. Do not use manually - automated use only! label Oct 6, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backport Changes, backported to release branch. Do not use manually - automated use only! label Oct 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [c557e77]

Summary: ✅

vdimir and others added 2 commits October 6, 2026 19:19
…123829

The previous commit copies master's body, which uses `allNodeFunctions`
and `IFunctionBase::hasObservableSideEffects`; 26.8 has neither, so
`Utils.cpp` does not compile. Check the same properties with what 26.8
has: a function that is non-deterministic within the query or stateful,
`sleep` and `sleepEachRow` by name (the only functions master reports as
having observable side effects), and any lambda, since on 26.8 neither
this check nor `dagContainsNonDeterministicFunction` looks into a lambda
body.

Related: #123829

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

groeneai commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Fix for the build failure

26.8 has neither allNodeFunctions nor IFunctionBase::hasObservableSideEffects (the errors on 34f42da). In my reply on #123829 (#123829 (comment)) I suggested removing the check on 26.8, but on 26.8 that would also remove the only check on this path that sees a lambda body: 26.8's dagContainsNonDeterministicFunction does not look into a lambda (26.9's and master's do, through allNodeFunctions). So the commit below keeps the function in Utils and writes its body in 26.8 terms: a function that is non-deterministic within the query or stateful, sleep and sleepEachRow by name, and any lambda.

The cost: on 26.8 a WHERE that also contains a lambda keeps reading the joined table, as before this backport. If that case matters, I can walk the lambda body instead (FunctionCapture and FunctionExpression expose it through getAcionsDAG()), at the price of a longer patch.

I checked exactly this tree on a local 26.8 debug build (clang-22): it builds; 05320_join_under_always_false_where_reads_nothing fails on 26.8 without #123829 and passes with it, also in 50 randomized runs; 161 filter push-down and join tests show no new failure; a WHERE with a lambda or with sleepEachRow keeps the input read, and stops doing so when that clause is removed. It is a fast-forward of this branch.

I have triage but not push, so applying it needs someone with push access:

git fetch https://github.com/groeneai/ClickHouse groeneai/fix-26.8-backport-123829 && git push origin FETCH_HEAD:backport/26.8/123829

Commit c557e772c51f.

@clickhouse-gh
clickhouse-gh Bot merged commit e69edad into 26.8 Oct 7, 2026
40 of 41 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.8/123829 branch October 7, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants