Skip to content

feat: add GroupColumn support for Decimal256 in multi-column GROUP BY#23849

Open
tohuya6 wants to merge 1 commit into
apache:mainfrom
tohuya6:feat-22715-decimal256-group-column
Open

feat: add GroupColumn support for Decimal256 in multi-column GROUP BY#23849
tohuya6 wants to merge 1 commit into
apache:mainfrom
tohuya6:feat-22715-decimal256-group-column

Conversation

@tohuya6

@tohuya6 tohuya6 commented Jul 23, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

multi_group_by::group_column_supported_type gates which GROUP BY columns may
use the column-wise GroupValuesColumn fast path, and the gate is
all-or-nothing: a single unsupported column forces the entire grouping onto
the byte-encoded GroupValuesRows fallback, even when every other key column
would have qualified. A Decimal256 key triggers exactly that today.

Although i256 is a 32-byte native rather than a machine-word scalar, it is
Copy and already implements ArrowNativeTypeOp + HashValue, so Decimal256
reuses the existing PrimitiveGroupValueBuilder with no new builder type and no
T: Copy relaxation — it mirrors the Decimal128 arm that already exists.

What changes are included in this PR?

  • Dispatch Decimal256Type in make_group_column, mirroring the Decimal128 arm.
  • Accept Decimal256(_, _) in group_column_supported_type.
  • Update the group_column_supported_typemake_group_column consistency
    fuzz: Decimal256 previously served as the stock unsupported example, so it
    moves into the supported set (Float16 / invalid Time unit combinations
    remain as the negative examples).
  • Add a Decimal256 group-count benchmark to benches/multi_group_by.rs.

Are these changes tested?

Yes.

  • New unit test: a Decimal256 key (precision > 38, so genuinely 256-bit) stays
    on the GroupValuesColumn path, dedups including nulls, and round-trips with
    the Decimal256(precision, scale) output type preserved.
  • The consistency fuzz now asserts Decimal256 routes through the dispatcher.
  • New single- and multi-column Decimal256 GROUP BY coverage in aggregate.slt.

Are there any user-facing changes?

No API changes. GROUP BY queries with a Decimal256 key now use the
column-wise fast path instead of the row-encoded fallback; results are unchanged.

…column 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
`Decimal256` key dragged an otherwise-qualifying multi-column GROUP BY onto the
slow path.

`Decimal256` mirrors the existing `Decimal128` arm and reuses
`PrimitiveGroupValueBuilder` with no new builder type: its `i256` native is
`Copy`, implements `ArrowNativeTypeOp`, and already implements `HashValue` via
`hash_integer!`, and the precision/scale round-trips through the builder's
stored `DataType`.

- dispatch `Decimal256(_, _)` in `make_group_column`
- accept `Decimal256(_, _)` in `group_column_supported_type`
- move `Decimal256` from the unsupported to the supported set in the
  `group_column_supported_type` <-> `make_group_column` consistency fuzz
- add an end-to-end unit test (Decimal256 GROUP BY dedups including nulls and
  preserves the Decimal256 precision/scale output type; uses precision > 38 so
  it is genuinely Decimal256) and a Decimal256 GROUP BY block (single- and
  multi-column keys) in aggregate.slt
- add a `(Decimal256, Int32)` group-count benchmark to `benches/multi_group_by.rs`

Part of apache#22715
@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) physical-plan Changes to the physical-plan crate labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant