Skip to content

feat(compute): add cumulative_sum and cumulative_sum_checked - #1139

Open
fallintoplace wants to merge 17 commits into
apache:mainfrom
fallintoplace:feat/compute-cumulative-sum
Open

feat(compute): add cumulative_sum and cumulative_sum_checked#1139
fallintoplace wants to merge 17 commits into
apache:mainfrom
fallintoplace:feat/compute-cumulative-sum

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

Arrow-Go has array and chunked-array compute kernels, but no cumulative sum operation for running totals. Adding this as a vector kernel also gives chunked inputs the same stateful behavior as a single contiguous array.

What changes are included in this PR?

  • Add cumulative_sum for signed integers, unsigned integers, and floating-point arrays.
  • Add cumulative_sum_checked, which reports integer overflow instead of returning an overflowing result.
  • Add CumulativeOptions with a start value and SkipNulls. By default, a null stops the cumulative result; with SkipNulls, null positions remain null while later valid values continue from the previous sum.
  • Validate cross-type start values with the same safe numeric conversion rules used by compute casts.
  • Carry the running state across chunks and keep the output chunked.

Are these changes tested?

  • go test ./arrow/compute/... -count=1
  • Added coverage for normal sums, null propagation, skipped nulls, start values, rejected overflow and truncation in start values, chunked input, and checked overflow at every integer width.

Are there any user-facing changes?

Yes. This adds the public compute.CumulativeSum and compute.CumulativeSumChecked functions plus CumulativeOptions. Existing functions and APIs are unchanged.

@fallintoplace
fallintoplace marked this pull request as ready for review August 9, 2026 00:00
@fallintoplace
fallintoplace marked this pull request as draft August 9, 2026 00:08
@fallintoplace
fallintoplace marked this pull request as ready for review August 9, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant