Skip to content

[C++][Compute] unique, value_counts and dictionary_encode have no kernel for float16 (halffloat) #50512

Description

@fornwall

Describe the enhancement requested

The hash-based vector functions do not support halffloat input, while supporting all other numeric types:

>>> import pyarrow as pa
>>> pa.array([1.5, 2.5], type=pa.float16()).dictionary_encode()
ArrowNotImplementedError: Function 'dictionary_encode' has no kernel matching input types (halffloat)

unique and value_counts fail the same way. Reproduced on current main; platform-independent (missing kernel registration, not a platform issue).

The cause is that AddHashKernels() in cpp/src/arrow/compute/kernels/vector_hash.cc registers kernels by iterating PrimitiveTypes(), which excludes float16 (FloatingPointTypes() is only {float32(), float64()}), and GetHashInit() has no Type::HALF_FLOAT case.

This was previously part of the broader GH-43017 ("Make the set of casts and hash kernels involving float16 consistent with other floating types", closed as stale); its PR #43018 stalled on the cast/sort parts, not the hash-kernel part. This issue proposes fixing only the hash kernels, registering float16 explicitly the same way recent merged float16 additions did (#46446 for if_else/replace, #46286 for run_end_encode), i.e. without widening FloatingPointTypes()/NumericTypes()/PrimitiveTypes(), whose other consumers are templated on the uint16_t storage type and would miscompute for half floats.

Component(s)

C++

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions