feat: parallel int sum/avg partials (#289 phase 5/6 slice 2) - #346
Merged
Conversation
Extend the parallel arm to sum/avg over int2/int4, completing the batch-eligible
kinds (count/sum/avg over int + float). sum(int) emits its int8 partial (NULL
until a value is seen, so the strict int8pl combine and its overflow check match
core's parallel sum); avg(int) emits the int8[2] {N,sum} array int4_avg_accum
builds, combined by int4_avg_combine and finalized by int8_avg -- built with
construct_array + explicit INT8OID params (not construct_array_builtin, same
cross-version reason as the float8 array).
Integer sums and numeric avg have no float reassociation, so the parallel fold
equals the serial oracle EXACTLY: parallel_vector_agg gains an exact sum(k)+avg(k)
check and a plan premise. 18/18 on pg15a/16a/17a/18a/19a assert.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UX1jrWiQsJJA1t4pkmkb4T
Owner
|
Verified locally on all five majors: 18/18 on PG15, 16, 17, 18 and 19. Branch already contains merged main (#343 + #344), and merged main itself gates clean across the matrix. Two things this gets right that are worth naming, because both were learned the hard way on #343:
The test property is also stronger than #343's, and correctly so: integer sums and numeric division have no reassociation, so parallel must equal serial exactly rather than within a tolerance. That makes any future divergence unambiguous instead of a judgement call about how much drift is acceptable. No objections from me. |
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.
What
Extends the parallel-aware ungrouped fold (#343) to sum/avg over int2/int4, completing the batch-eligible kinds for parallelism (count / sum / avg over int and float).
count(*), avg(float8)was #343; this adds the integer measures common in analytics.Follow-up to #343 (now merged): extends the same parallel-fold pattern to integer measures.
How
Same shape as #343 (parallel partial
ColumnarAgg→ Gather → core Finalize), extending only the per-worker partial emission:sum(int2/int4)→ its int8 partial, NULL until a value is seen so the strictint8plcombine (and its overflow check) match core's own parallelsum(int).avg(int2/int4)→ the int8[2]{N, sum}arrayint4_avg_accumbuilds, combined byint4_avg_combineand finalized byint8_avgto numeric. Built withconstruct_array+ explicitINT8OIDparams (notconstruct_array_builtin, same cross-version reason as feat: parallel-aware ungrouped vectorized batch fold (#289 phase 5/6) #343's float8 array).Tests
Integer sums and numeric avg have no float reassociation, so the parallel fold equals the serial oracle exactly (not within tolerance).
parallel_vector_agg.shgains an exactsum(k)+avg(k)check plus a plan premise that the int aggregate takes the parallel fold. 18/18 on pg15a/16a/17a/18a/19a assert.🤖 Generated with Claude Code