Skip to content

COUNT(DISTINCT) on Decimal32/Decimal64 doesn’t use the native distinct accumulator #26820

Description

@tjnangosha

Is your feature request related to a problem or challenge?

COUNT(DISTINCT) on a Decimal32 or Decimal64 column is slower than on a Decimal128 column, even though the values are smaller. In the count_distinct benchmark, a batch of 8,192 Decimal32 values takes about 870 µs, compared with about 110 µs for Decimal128.

get_count_accumulator in datafusion/functions-aggregate/src/count.rs sends Decimal128 and Decimal256 to PrimitiveDistinctCountAccumulator, but has no arm for Decimal32 or Decimal64. They fall through to the generic DistinctCountAccumulator, which converts every row into a ScalarValue.

Describe the solution you'd like

Add Decimal32 and Decimal64 arms to get_count_accumulator that use PrimitiveDistinctCountAccumulator, matching Decimal128 and Decimal256.

Describe alternatives you've considered

No response

Additional context

No response

Willingness to contribute

I plan to contribute to this feature independently

Activity

  1. tjnangosha commented on Oct 27, 2026

    @tjnangosha
    ContributorAuthor

    take

  2. added a commit that references this issue on Oct 29, 2026
    de6f3e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions