Uh oh!
There was an error while loading. Please reload this page.
Add FixedSizeBinary support for MultiGroupBy - #23646
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #23646 +/- ##
==========================================
+ Coverage 81.05% 81.07% +0.01%
==========================================
Files 1106 1107 +1 Lines 380556 380929 +373 Branches 380556 380929 +373 ==========================================
+ Hits 308477 308842 +365 - Misses 53861 53865 +4 - Partials 18218 18222 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
alamb
commented
Jul 16, 2026
alamb
commented
Jul 16, 2026
There is also this PR However I don't think that will handle FixedSizeBinary |
Rich-T-kid
left a comment
There was a problem hiding this comment.
This PR looks very reasonable. I noticed that this is very similar to the ByteGroupValueBuilder implementation.
I think it would be worth it to try and see if we can modify ByteGroupValueBuilder to support similar optimizations such as batched writes. besides that vectorized/equal_to and the other trait methods are 1-1.
If ByteGroupValueBuilder cant be expanded on to include fixed size binary without extensive branching that hurts readability thats also fine.
| impl GroupColumn for FixedSizeBinaryGroupValueBuilder { | ||
| fn equal_to(&self, lhs_row: usize, array: &ArrayRef, rhs_row: usize) -> bool { | ||
| debug_assert!(matches!(array.data_type(), DataType::FixedSizeBinary(_))); |
There was a problem hiding this comment.
the array input is guaranteed to be the correct type. you can remove the assertion here
| rhs_rows: &[usize], | ||
| equal_to_results: &mut BooleanBufferBuilder, | ||
| ) { | ||
| debug_assert!(matches!(array.data_type(), DataType::FixedSizeBinary(_))); |
Uh oh!
There was an error while loading. Please reload this page.
alamb
commented
Jul 16, 2026
This sounds like a good thing to explore in a follow on / parallel PR |
alamb
commented
Jul 16, 2026
Since I think the point of doing this PR is to improve performance it would be nice to have some benchmark results I created a PR with some benchmarks here Hopefully we can merge that and then use it to validate that this PR improves things |
maxburke
commented
Jul 16, 2026
More so that if we're grouping by a FixedSizeBinary column we run out of memory in the GroupValuesRows interning and crash :) |
e843517 to
f8ebf73Compare…he#23650) ## Which issue does this PR close? - Related to apache#23646 - Related to apache#23645. ## Rationale for this change The point of a specialized FixedSizeBinary group values is performance but we have no performance benchmark for it. ## What changes are included in this PR? Adds a `fixed_size_binary` experiment to `datafusion/physical-plan/benches/multi_group_by.rs` Run with: ```bash cargo bench -p datafusion-physical-plan --bench multi_group_by --features test_utils -- fixed_size_binary ``` ## Are these changes tested? This is benchmark-only. The benchmark compiles on `main` and runs end-to-end on top of apache#23646. No product code changes. ## Are there any user-facing changes? No. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
alamb
commented
Jul 17, 2026
Can you please merge this PR up from main (so I can run the benchmarks using the bot?) I can't do it myself b/c I don't have write permissions int he urbanlogiq repo |
maxburke
commented
Jul 17, 2026
done! |
3970070 to
5eb8979Compare
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
alamb
commented
Aug 3, 2026
run benchmark multi_group_by |
adriangbot
commented
Aug 3, 2026
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing multi-group-by-fsb (5eb8979) to 4957f5d (merge-base) diff Run configurationrun benchmark multi_group_buResults will be posted here when complete File an issue against this benchmark runner |
adriangbot
commented
Aug 3, 2026
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing multi-group-by-fsb (5eb8979) to 4957f5d (merge-base) diff Run configurationrun benchmark multi_group_byResults will be posted here when complete File an issue against this benchmark runner |
adriangbot
commented
Aug 3, 2026
Benchmark for this request failed. Run configurationrun benchmark multi_group_byLast 20 lines of output: Click to expandFile an issue against this benchmark runner |
adriangbot
commented
Aug 3, 2026
Benchmark for this request failed. Run configurationrun benchmark multi_group_buLast 20 lines of output: Click to expandFile an issue against this benchmark runner |
alamb
commented
Aug 3, 2026
run benchmark multi_group_by |
adriangbot
commented
Aug 3, 2026
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing multi-group-by-fsb (5eb8979) to 4957f5d (merge-base) diff Run configurationrun benchmark multi_group_byResults will be posted here when complete File an issue against this benchmark runner |
adriangbot
commented
Aug 3, 2026
Benchmark for this request failed. Run configurationrun benchmark multi_group_byLast 20 lines of output: Click to expandFile an issue against this benchmark runner |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
alamb
left a comment
There was a problem hiding this comment.
Thanks @maxburke and @Rich-T-kid
I reviewed the code and it looks good to me
I also did some ad-hoc performance testing with it like this:
Made a datafile like this
COPY (
SELECT
arrow_cast(decode(md5((value % 5000000)::varchar), 'hex'), 'FixedSizeBinary(16)') AS uuid,
(value % 10) AS id
FROM generate_series(1, 200000000)
) TO 'uuids.parquet';This looks like this
andrewlamb@Andrews-MacBook-Pro-3:~/Downloads$ du -s -h uuids.parquet
3.0G uuids.parquet>select*from'uuids.parquet'limit10;
+----------------------------------+----+
| uuid | id |
+----------------------------------+----+
| ae3fcf8bfebbc45af3bf12f70d9d3acd | 5 |
| c94adce9d37cb5fde98966e278815c64 | 6 |
| 2bc049eddc1314ec3bee9509f935741b | 7 |
| 76b22168b7e87edca43468290be51218 | 8 |
| aa59f82ba5a34a3d3c25773d8a948e99 | 9 |
| 657aa03184c164a30af703a02e2a687b | 0 |
| 491f0cbcf7b88ac92d2adff2a0528d81 | 1 |
| 17da0cbc4ffef7f04b4e3a2283160fd7 | 2 |
| 81a1f57e643d79dfcee6cd4117d43c30 | 3 |
| f0b301dad7ddd5eb3ea3d854823cc798 | 4 |
+----------------------------------+----+10 row(s) fetched.
Elapsed 0.021 seconds.And then ran this query:
SELECTcount(*) FROM (SELECT uuid, id FROM'uuids.parquet'GROUP BY uuid, id);On main: 1.132 seconds.
With this PR: 1.073 seconds.
(this was a very noisy system)
| ) { | ||
| let array = array.as_fixed_size_binary(); | ||
| for (idx, (&lhs_row, &rhs_row)) in |
There was a problem hiding this comment.
As a follow on, this can likely be optimized more -- for example, we could have a special case loop for when the inputs are known to have no nulls (likely a common case for things like UUIDs)
We could also move to using get_unchecked to skip the bounds check and try to make this lookup loop even more performant
There was a problem hiding this comment.
I filed this ticket to track
| Nulls::Some | ||
| }; | ||
| match all_null_or_non_null { |
alamb
commented
Aug 11, 2026
Thanks again @maxburke |
maxburke
commented
Aug 11, 2026
You're welcome! |
…he#23650) ## Which issue does this PR close? - Related to apache#23646 - Related to apache#23645. ## Rationale for this change The point of a specialized FixedSizeBinary group values is performance but we have no performance benchmark for it. ## What changes are included in this PR? Adds a `fixed_size_binary` experiment to `datafusion/physical-plan/benches/multi_group_by.rs` Run with: ```bash cargo bench -p datafusion-physical-plan --bench multi_group_by --features test_utils -- fixed_size_binary ``` ## Are these changes tested? This is benchmark-only. The benchmark compiles on `main` and runs end-to-end on top of apache#23646. No product code changes. ## Are there any user-facing changes? No. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Closesapache#23645 - part of apache#22715 ## Rationale for this change Multi-Group-By has cases for regular Binary/LargeBinary types, but not FixedSizeBinary ## Are these changes tested? Yes. ## Are there any user-facing changes? No Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Rationale for this change
Multi-Group-By has cases for regular Binary/LargeBinary types, but not FixedSizeBinary
Are these changes tested?
Yes.
Are there any user-facing changes?
No