diff --git a/cpp/src/arrow/compute/kernels/vector_hash.cc b/cpp/src/arrow/compute/kernels/vector_hash.cc index 90ec9e365c3..f42972e18af 100644 --- a/cpp/src/arrow/compute/kernels/vector_hash.cc +++ b/cpp/src/arrow/compute/kernels/vector_hash.cc @@ -550,6 +550,7 @@ KernelInit GetHashInit(Type::type type_id) { return HashInit>; case Type::INT16: case Type::UINT16: + case Type::HALF_FLOAT: return HashInit>; case Type::INT32: case Type::UINT32: @@ -700,6 +701,13 @@ void AddHashKernels(VectorFunction* func, VectorKernel base, OutputType out_ty) DCHECK_OK(func->AddKernel(base)); } + // float16() is not part of PrimitiveTypes() (FloatingPointTypes() only covers + // float32 and float64; see GH-43017), so it must be registered explicitly. Like + // float32 and float64, it is hashed by its raw bit pattern (via UInt16Type). + base.init = GetHashInit(Type::HALF_FLOAT); + base.signature = KernelSignature::Make({float16()}, out_ty); + DCHECK_OK(func->AddKernel(base)); + // Parametric types that we want matching to be dependent only on type id auto parametric_types = {Type::TIME32, Type::TIME64, Type::TIMESTAMP, Type::DURATION, Type::FIXED_SIZE_BINARY}; diff --git a/cpp/src/arrow/compute/kernels/vector_hash_test.cc b/cpp/src/arrow/compute/kernels/vector_hash_test.cc index b0fa296e007..b11e0a722a5 100644 --- a/cpp/src/arrow/compute/kernels/vector_hash_test.cc +++ b/cpp/src/arrow/compute/kernels/vector_hash_test.cc @@ -150,8 +150,8 @@ template class TestHashKernelPrimitive : public ::testing::Test {}; typedef ::testing::Types + UInt32Type, Int64Type, UInt64Type, HalfFloatType, FloatType, + DoubleType, Date32Type, Date64Type> PrimitiveDictionaries; TYPED_TEST_SUITE(TestHashKernelPrimitive, PrimitiveDictionaries);