Skip to content

docs(arrow/compute): say what MergeAll returns for no states and where Ordered takes effect - #1338

Merged
zeroshade merged 2 commits into
apache:mainfrom
singhpratech:doc-mergeall-empty
Oct 5, 2026
Merged

zeroshade merged 2 commits into
apache:mainfrom
singhpratech:doc-mergeall-empty

Conversation

@singhpratech

Copy link
Copy Markdown
Contributor

Follow-up to #1336, docs only.

The review noted two things worth a sentence in the comments:

  • MergeAll returns (nil, nil) for an empty states slice, and a caller reading "returns the state you then finalize" could finalize nil. The comment now says so, and says what to do instead: aggregate the empty input the way the executor does, one state from init, then finalize.
  • Ordered has no effect on the in-tree executor, which consumes the whole input into a single state in order. The comment now says that it is a contract for MergeAll and for callers that partition the input themselves.

No code change. gofmt, go vet and go test on arrow/compute and arrow/compute/exec are clean.

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two additions are accurate against the executor. One wording fix is needed, plus two nits.

An older comment also contradicts the new one. It's outside the diff, so it can't go inline: the ScalarAggCleanup doc (L144-145) still says cleanup runs when the aggregation "produced no result because the input was empty". The executor always finalizes empty input. Suggest "…whether the aggregation succeeded, saw no input, was cancelled, or failed…" to match the scalarAggExecutor doc.

Comment thread arrow/compute/exec/aggregate.go Outdated
// whose result does not depend on the order of the input leave this
// false.
//
// The executor in this package consumes the whole input into a single

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The executor isn't in this package (exec). scalarAggExecutor lives in compute. Suggest "The executor in the compute package…", which matches the AggregateResult doc.

Comment thread arrow/compute/exec/aggregate.go Outdated
// With no states there is nothing to merge or to finalize, and MergeAll
// returns (nil, nil). A caller that ended up with zero partitions aggregates
// the empty input the way the executor does: create one state with the init
// function and finalize it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "…and finalize it, then clean it up." The paragraph above says callers never clean up states passed to MergeAll, but this state is the caller's to clean up.

…ition caller cleans its state up, ScalarAggCleanup's cases match the executor doc
@singhpratech

Copy link
Copy Markdown
Contributor Author

All three taken, thanks: "the executor in the compute package", "finalize it, then clean it up", and the
ScalarAggCleanup cases now read "succeeded, saw no input, was cancelled, or failed in init, consume,
merge or finalize", matching the scalarAggExecutor doc. Pushed as one commit on top.

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — all three points from the last pass are in 0048482, and the ScalarAggCleanup wording now matches the scalarAggExecutor doc. Re-checked the new text against the code: MergeAll does return (nil, nil) for no states, and scalarAggExecutor builds a single state and never calls MergeAll or reads Ordered, so both new paragraphs are accurate. LGTM.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Arrow handles maintainer review:
CONTRIBUTING.md.

@zeroshade
zeroshade merged commit 4d5bd6a into apache:main Oct 5, 2026
35 of 45 checks passed
singhpratech added a commit to singhpratech/ArrowMetal that referenced this pull request Oct 6, 2026
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.

2 participants