Repository navigation
Lower ArrayJoin with nondeterministic functions - #122240
Conversation
…or the old placement
…oin-with-nondeterministic # Conflicts: # src/Core/SettingsChangesHistory.cpp
|
Workflow [PR], commit [c02f5b8] Summary: ✅
AI ReviewSummaryThis PR changes PR Metadata
Findings❌ Blockers
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit c02f5b8.
Changed lines: Changed C/C++ lines covered: 55/57 (96.49%) · Uncovered code |
…deterministic ones before
…oin-with-nondeterministic Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
nihalzp
left a comment
There was a problem hiding this comment.
Mostly looks good. I left a reply on the automatic review thread.
Additionally, I feel the proposed setting name may not be very clear to the users. I propose legacy_array_join_function_nondeterministic_evaluation (default false: gives different value on every output row; previous value true: one value per source row, repeated across that row's expanded rows).
… rename the setting to legacy_array_join_function_nondeterministic_evaluation
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1233 translation units recompiled, 8947 s compile time in total, 1233 of them have a recent master baseline. |
Since ClickHouse#122240, `query_plan_lower_array_join_function` also lowers an `arrayJoin` that sits next to other conjuncts in a HAVING filter: the plan becomes `ArrayJoin -> Filter(count() > 3) -> Aggregating`, so the filter directly above the aggregation no longer holds the `arrayJoin` and the pre-filter legitimately attaches to it. The `array join in having` cell then saw the annotation and failed in the merge queue (`0` expected, `1` observed). The cell exists to exercise the `hasArrayJoin` refusal, so it now pins the lowering off, which keeps the `arrayJoin` inside the filter the pass reads. The lowered shape gets its own applied cell and an exact skipped-group pair (4000 of 6000 groups skipped on the `on` arm, the same rows as the `off` arm and as the un-lowered plan). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…plication again No existing query number or text changes: 1 query is disabled and 1 appended as 2. Since ClickHouse#122240 a non-deterministic function next to `arrayJoin` is evaluated once per output row, so query 0 builds 10240 strings of 1 MiB (3.41 s amd / 2.91 s arm on MasterCI, 16 GiB) and replicates none: with `enable_lazy_columns_replication = 0` it takes the same time. The copy takes the string from a subquery, which is fixed per source row, so `arrayJoin` replicates it again, as query 0 did before ClickHouse#122240. On the official amd builds right before ClickHouse#122240, of its merge and of master, the copy takes 0.002-0.003 s and 3.57-3.69 s (over 1000x) with lazy replication off, the same eager work as the old query 0 (0.997-1.03); query 0 was over 1000x slower without lazy replication before ClickHouse#122240 and takes the same time after. Saves about 40 s of query time per master perf job on amd. Related: ClickHouse#129258 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #112241
Related: #117882
Related: #120390
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
With
query_plan_lower_array_join_functionenabled, a non-deterministic function such asrand()orgenerateUUIDv4()next toarrayJoinin the sameSELECTis evaluated once per output row, as with theARRAY JOINclause, instead of once per source row. Setarrayjoin_nondeterministic_functions_before_expansion = 1(orcompatibilityto 26.9 or older) to keep the previous behaviour.Workflow [PR]
Sync PR [sync-upstream/pr/122240]
Version info
26.10.1.1071-master(included in26.10and later)