feat: add native GroupsAccumulator for any_value#23065
Draft
Kevin-Li-2025 wants to merge 4 commits into
Draft
Conversation
added 4 commits
June 19, 2026 13:14
Signed-off-by: Kevin-Li-2025 <2242139@qq.com>
…s-accumulator # Conflicts: # datafusion/functions-aggregate/Cargo.toml
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.
Which issue does this PR close?
Follow-up to #23043. This draft is stacked on that PR and should be reviewed after it merges.
Rationale for this change
Grouped
any_valuecurrently falls back toGroupsAccumulatorAdapter, which creates one boxedAccumulatorper group, collects row indices, materializes per-group slices, and performs dynamic dispatch for every group. That overhead dominates high-cardinalityGROUP BYworkloads even thoughany_valueonly needs to retain one non-null value per group.This PR adds a native
GroupsAccumulatorthat:ScalarValueand oneis_setbit per group;EmitTo::First, andconvert_to_state; andany_value.What changes are included?
GroupsAccumulatorAdapterfor Int64 and Utf8 at 8,192 rows / 4,096 groups.Local Apple Silicon benchmark medians:
The Utf8 adapter result is allocator-sensitive, so the claim is intentionally conservative.
Validation
cargo test -p datafusion-functions-aggregate --lib(146 passed)cargo clippy -p datafusion-functions-aggregate --all-targets -- -D warningscargo fmt --all -- --checkcargo bench -p datafusion-functions-aggregate --bench any_value -- --noplotgit diff --check