Repository navigation
Conversation
A lambda that captures a column is a FUNCTION node whose function_base is a FunctionCapture. buildFilterActionsDAG re-adds functions with an empty name, so the node is renamed to its signature, e.g. `Capture[UInt64](UInt64) -> UInt8(v)`, and ActionsDAG::Node::updateHash hashed only names, types and children. So `x -> x < v` and `x -> x > v` over the same columns got one query condition cache key, and a MergeTree WHERE (or a File/S3 format filter) reused the other lambda's "no row matches" marks and skipped matching granules. Also hash the capture binding (captured column names and lambda argument names, in order) and the lambda body, which is how ActionsDAG::serialize already describes the same node. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding) and my own cold review of the diff.
Severity: ❌ blocker / Session id: cron:clickhouse-review-self-slot-58:20260929-201800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-self-slot-57:20260929-192200 |
|
Workflow [PR], commit [14a6261] Summary: ✅
AI ReviewSummaryReviewed #122966 at Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units7 translation units recompiled, 18 s compile time in total, 7 of them have a recent master baseline. |
|
Dear @yariks5s, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
Conflict in `ActionsDAG::Node::updateHash`, which master split into `updateOwnHash` and whose lambda capture and body hashing (ClickHouse#116781) runs only in build-independent mode. That block now runs in both modes, replacing this branch's own exact-mode copy: the query condition cache keys on exact hashes of DAGs built by `buildFilterActionsDAG`, where a lambda node is named only by its signature, so the exact hash also needs the body. Exact mode only gains data, so no two nodes that hashed apart before hash alike now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #122804
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed wrong results when queries on the same table filter with different lambdas that capture a column, for example
arrayExists(x -> x < v, arr)and thenarrayExists(x -> x > v, arr): the query condition cache used one key for both, so the second query skipped granules with matching rows.Description
On 26.8.2.7 (and 26.3.33.24), with default settings, the second query returns 0 instead of 10000:
A lambda that captures columns is a
FunctionCapturenode.buildFilterActionsDAGrenames it to its signature (Capture[UInt64](UInt64) -> UInt8(v)), and the exactActionsDAG::Node::updateHashthat the query condition cache keys on does not hash the lambda body, so both lambdas get the same key. Binding the lambda arguments in another order ((y, x) -> ...vs(x, y) -> ...) collides the same way.#116781 hashes the capture and the body, as
ActionsDAG::serializedescribes them, but only in build-independent mode. This PR applies that hashing to exact hashes too. Every query condition cache key (MergeTree WHERE, PREWHERE, index analysis, File/S3 and data lake filters, Memory) and the in-memory plan statistics keys use this hash. Exact hashing only gains data, so only DAGs that contain a lambda get new hashes.The new test fails on master in both cases (20/20 randomized runs) and passes with the fix (40/40); 310 related tests (query condition cache, lambdas, Auto-PR, join build-side statistics) show no new failure.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/122966]