feat: add GroupColumn support for Float16 in multi-column GROUP BY - #23785
feat: add GroupColumn support for Float16 in multi-column GROUP BY#23785tohuya6 wants to merge 4 commits into
Conversation
…umn GROUP BY `multi_group_by::group_column_supported_type` gates which GROUP BY columns can use the column-wise `GroupValuesColumn` fast path. Any unsupported column forces the entire grouping onto the byte-encoded `GroupValuesRows` fallback, so a single `Float16` key dragged an otherwise-qualifying multi-column GROUP BY onto the slow path. `Float16` reuses the existing `PrimitiveGroupValueBuilder` with no new builder type: its native `half::f16` already implements the `HashValue` canonicalization (`hash_float!(f16, f32, f64)`), so `-0.0` / `+0.0` folding and NaN grouping match Float32 / Float64 with no extra handling. - accept `Float16` in `group_column_supported_type` and dispatch it in `make_group_column` - move `Float16` from the rejected to the accepted set in the `group_column_supported_type` <-> `make_group_column` consistency fuzz, and repoint the two tests that used `Float16` as their stock "unsupported" example to a permanently-invalid unit combo (`Time64(Second)`), so they stay stable as sibling primitive builders (Decimal256, Interval, ...) land - add an end-to-end unit test (Float16 GROUP BY dedups including nulls, folds -0.0/+0.0 into one group stored as +0.0, groups equal NaNs, and preserves the Float16 output type) and a Float16 GROUP BY block in aggregate.slt - add a `(Float16, Int32)` group-count benchmark to `benches/multi_group_by.rs` (capped below f16's ~63.5k distinct finite values) Part of apache#22715
| fn test_group_values_column_float16() { | ||
| use half::f16; | ||
|
|
||
| let schema = |
There was a problem hiding this comment.
Nice test! One small suggestion: since the user-visible regression is the all-or-nothing multi-column gate, it might be worth making this schema (Float16, Int32) instead of a single Float16 column.
That would let the test assert that (-0.0, 3) and (+0.0, 3) resolve to the same group, while values like (0.0, 4) remain distinct because the Int32 key differs. The SLT already verifies the SQL behaviour, but this would exercise the exact multi-column GroupValuesColumn path and make the gate and factory integration a little more explicit.
There was a problem hiding this comment.
I appreciate the advice, tried to make the distinction clearer
… unit test Per kosiew's review: a single-column Float16 test doesn't exercise the all-or-nothing multi-column gate this PR is actually about. Switching to (Float16, Int32) does — group count goes from 4 (single column: 1.0, ±0.0, NaN, null) to 5, since (0.0, 4) now splits off from (±0.0, 3) on the Int32 key even though the Float16 values are equal. Also trimmed the slt/test comments to match the Duration and Interval siblings.
…he GroupColumn unit test Per kosiew's review: a single-column Duration test doesn't exercise the all-or-nothing multi-column gate this PR is actually about. Switching to (Duration(Microsecond), Int64) does — rows 3 and 4 now repeat row 0 and the (null, null) pair across both columns, so dedup is proven on the composite key rather than the Duration value alone. Also renumber the bench to Experiment 9 (float16 apache#23785 takes 8) and trim the slt/test comments to match the sibling PRs.
The 30-days case duplicated the slt, which already proves 1 month and 30 days don't fold. Dropping it leaves the assertions unique to the unit level: null keys dedup, the Int32 key splits equal intervals, and emit gives back Interval rather than the raw native. Also renumber the bench to Experiment 10 (float16 apache#23785 takes 8, duration apache#23783 takes 9), trim comments to match the sibling PRs, and normalize the blank lines after the new slt block to two, matching upstream.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23785 +/- ##
==========================================
- Coverage 80.86% 80.85% -0.01%
==========================================
Files 1099 1101 +2
Lines 374766 374984 +218
Branches 374766 374984 +218
==========================================
+ Hits 303058 303209 +151
- Misses 53617 53676 +59
- Partials 18091 18099 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@tohuya6 |
Duration apache#23783 landed on main and touched the same regions as this PR. Kept both sides: - mod.rs: unioned the arrow imports, kept both unit tests, Float16 added to the supported arms - benches: Float16 stays Experiment 8, Duration keeps 9 - group_by.slt: both coverage blocks
|
@kosiew resolved |
Which issue does this PR close?
Rationale for this change
multi_group_by::group_column_supported_typegates which GROUP BY columns mayuse the column-wise
GroupValuesColumnfast path, and the gate isall-or-nothing: a single unsupported column forces the entire grouping onto
the byte-encoded
GroupValuesRowsfallback, even when every other key columnwould have qualified. A
Float16key triggers exactly that today.Float16reuses the existingPrimitiveGroupValueBuilderwith no new buildertype: its native
half::f16already implements theHashValuecanonicalization (
hash_float!(f16, f32, f64)), so-0.0/+0.0folding andNaNgrouping matchFloat32/Float64with no extra handling.What changes are included in this PR?
Float16ingroup_column_supported_typeand dispatch it inmake_group_column.Float16from the rejected to the accepted set in thegroup_column_supported_type↔make_group_columnconsistency fuzz, andrepoint the two tests that used
Float16as their stock "unsupported" exampleto a permanently-invalid unit combo (
Time64(Second)), so they stay stable assibling primitive builders (Decimal256, Interval, …) land independently.
(Float16, Int32)group-count benchmark tobenches/multi_group_by.rs(capped below f16's ~63.5k distinct finite values).
Are these changes tested?
Yes.
test_group_values_column_float16: a(Float16, Int32)keystays on the
GroupValuesColumnpath, dedups including nulls, folds-0.0/+0.0into one group (stored as+0.0), groups equalNaNs, keeps(0.0, 4)distinct from(±0.0, 3)via theInt32key, and round-tripswith the
Float16output type preserved.Float16routes through the dispatcher.Float16GROUP BYcoverage ingroup_by.slt.Are there any user-facing changes?
No API changes.
GROUP BYqueries with aFloat16key now use the column-wisefast path instead of the row-encoded fallback; results are unchanged.