Skip to content

Cherry-pick apache/datafusion#23187 (dependency of #25185) - #183

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

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

Conversation

@LiaCastaneda

Copy link
Copy Markdown

cherry-picks apache#23187 onto branch-55.

Prerequisite for cherry-picking apache#25185 (perf: reuse cached dictionary value hashes in vectorized_append) onto branch-55. That PR patches multi_group_by/dictionary.rs, which does not exist on branch-55 (it was ported to branch-54 via #171 but never forward-ported to branch-55). This PR creates that file by porting the original upstream PR that introduced it: "Feat: add dictionaries as a supported group column type".

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

Next in the chain: apache#24418 (adds the value-hash cache that apache#25185 extends).

## 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.
-->

- works towards closing apache#22682.
- replacement for apache#21765
- -
apache#21765 (review)

## Rationale for this change

This PR introduces a specialized `GroupColumn` implementation for
dictionary-typed columns inside `GroupValuesColumn`, allowing dictionary
columns to participate in the columnar, vectorized aggregation path
instead of the row-based fallback.

**The Implementation is only about 175+ lines of code**. the remaining
LOC is adding extensive test at the `GroupColumn` trait level as well as
testing the `GroupValuesColumn` GroupValues trait and how it inter-opts
with multi-dictionary group by's.
<!--
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.
-->

## What changes are included in this PR?

- Adds a `DictionaryGroupValueBuilder` struct implementing the
`GroupColumn` trait for `Dictionary`-typed group-by columns, supporting
a configurable subset of value types
- Extends the type-check gate in `GroupValuesColumn::try_new` (the
`matches!` block) to accept `Dictionary(_, value_type)` where
`value_type` is already supported.
- Adds schema-level support so emitted dictionary group key columns
round-trip through the output schema correctly
- [removes casting
](https://github.com/apache/datafusion/blob/9e8dd76d6deb6736c51962d9c97e04be4e3f1fc9/datafusion/physical-plan/src/aggregates/group_values/multi_group_by/mod.rs#L1200)thats
done for each dictionary array in `emit`
<!--
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?
yes. a majority of this PR is test
<!--
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. this is a pure perf boost for users.
<!--
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.
-->

(cherry picked from commit c1b39bd)
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12579% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.18%. Comparing base (d7eb121) to head (47a5075).

Files with missing lines Patch % Lines
...gregates/group_values/multi_group_by/dictionary.rs 94.99% 13 Missing and 16 partials ⚠️
.../src/aggregates/group_values/multi_group_by/mod.rs 96.49% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           branch-55     #183      +/-   ##
=============================================
+ Coverage      81.15%   81.18%   +0.02%     
=============================================
  Files           1110     1111       +1     
  Lines         386654   387278     +624     
  Branches      386654   387278     +624     
=============================================
+ Hits          313798   314397     +599     
- Misses         54365    54375      +10     
- Partials       18491    18506      +15     

☔ 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 merged commit 81480cb 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