Skip to content

Cherry-pick apache/datafusion#24418 - #184

Merged
LiaCastaneda merged 1 commit into
DataDog:branch-55from
LiaCastaneda:lia.castaneda/cherry-pick/apache-pr-24418-20260916
Sep 16, 2026
Merged

LiaCastaneda merged 1 commit into
DataDog:branch-55from
LiaCastaneda:lia.castaneda/cherry-pick/apache-pr-24418-20260916

Conversation

@LiaCastaneda

Copy link
Copy Markdown

cherry-picks apache#24418 onto branch-55, stacked on #183.

Depends on #183 (apache#23187, which creates multi_group_by/dictionary.rs) landing first — this PR's diff will shrink to just this commit once #183 merges.

Second prerequisite for cherry-picking apache#25185 onto branch-55: adds the val_to_inner/val_hashes Arc-pointer cache for the scalar append_val path that apache#25185 extends to the vectorized path.

Auto-merged with no conflicts. cargo check -p datafusion-physical-plan and cargo test -p datafusion-physical-plan --lib aggregates::group_values (82/82) pass.

@codecov-commenter

codecov-commenter commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.18%. Comparing base (81480cb) to head (63d89aa).
⚠️ Report is 1 commits behind head on branch-55.

Files with missing lines Patch % Lines
...gregates/group_values/multi_group_by/dictionary.rs 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           branch-55     #184   +/-   ##
==========================================
  Coverage      81.18%   81.18%           
==========================================
  Files           1111     1111           
  Lines         387278   387293   +15     
  Branches      387278   387293   +15     
==========================================
+ Hits          314396   314416   +20     
+ Misses         54379    54371    -8     
- Partials       18503    18506    +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LiaCastaneda LiaCastaneda changed the title Cherry-pick apache/datafusion#24418 (dependency of #25185) Cherry-pick apache/datafusion#24418 Sep 16, 2026
## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->

- Closes apache#23921.
- this PR was created on top of apache#24416, so once that is merged in we can
rebase this branch

## Rationale for this change

append_val is called once per new group on the scalar (streaming) code
path. Previously it hashed a single-element slice of the dictionary
values array on every call, paying create_hashes fixed overhead 65k
times for a high-cardinality batch. Caching the full values array hash
keyed on Arc::ptr_eq collapses that to one vectorized hash pass per
batch, yielding a 2× speedup on the all-unique case with no measurable
regression elsewhere.

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.

Please explain the problem you are trying to solve in terms of the
user-visible
behavior, rather than the implementation.

For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of
the
implementation. "COUNT(DISTINCT) returns wrong results when the column
contains
nulls" is the user-visible problem.
-->

## What changes are included in this PR?

- DictionaryGroupValuesColumn gains a cached_values: Option<ArrayRef>
field
- append_val: on a cache miss (Arc::ptr_eq fails), hashes the entire
dict.values() array into val_hashes and stores the Arc; on a hit, reuses
val_hashes[val_idx] directly — eliminating the per-call slice(val_idx,
1) allocation and create_hashes call

<!--
There is no need to duplicate the description in the issue here, but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

## Are these changes tested?
nothing logically changed.
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

## Are there any user-facing changes?
no
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.

If there are any breaking changes to public APIs, please add the `api
change` label.
-->

---------

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
(cherry picked from commit 66a901f)
@LiaCastaneda
LiaCastaneda force-pushed the lia.castaneda/cherry-pick/apache-pr-24418-20260916 branch from c77cc2d to 63d89aa Compare September 16, 2026 11:51
@LiaCastaneda
LiaCastaneda merged commit 7a58ec4 into DataDog:branch-55 Sep 16, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants