Skip to content

Commit 4d9228f

Browse files
GH-15226: [C++] Add DurationType to hash kernels (#33685)
`DurationType` was missing in the function to register the hash-based kernels (unique, dictionary_encode, etc) * Closes: #15226 Authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent 7e6bcd1 commit 4d9228f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cpp/src/arrow/compute/kernels/vector_hash.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ void AddHashKernels(VectorFunction* func, VectorKernel base, OutputType out_ty)
719719

720720
// Example parametric types that we want to match only on Type::type
721721
auto parametric_types = {time32(TimeUnit::SECOND), time64(TimeUnit::MICRO),
722-
timestamp(TimeUnit::SECOND), fixed_size_binary(0)};
722+
timestamp(TimeUnit::SECOND), duration(TimeUnit::SECOND),
723+
fixed_size_binary(0)};
723724
for (const auto& ty : parametric_types) {
724725
base.init = GetHashInit<Action>(ty->id());
725726
base.signature = KernelSignature::Make({ty->id()}, out_ty);

cpp/src/arrow/compute/kernels/vector_hash_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ TEST_F(TestHashKernel, UniqueTimeTimestamp) {
315315

316316
CheckUnique<TimestampType, int64_t>(timestamp(TimeUnit::NANO), {2, 1, 2, 1},
317317
{true, false, true, true}, {2, 0, 1}, {1, 0, 1});
318+
CheckUnique<DurationType, int64_t>(duration(TimeUnit::NANO), {2, 1, 2, 1},
319+
{true, false, true, true}, {2, 0, 1}, {1, 0, 1});
318320
}
319321

320322
TEST_F(TestHashKernel, ValueCountsTimeTimestamp) {
@@ -329,6 +331,9 @@ TEST_F(TestHashKernel, ValueCountsTimeTimestamp) {
329331
CheckValueCounts<TimestampType, int64_t>(timestamp(TimeUnit::NANO), {2, 1, 2, 1},
330332
{true, false, true, true}, {2, 0, 1},
331333
{1, 0, 1}, {2, 1, 1});
334+
CheckValueCounts<DurationType, int64_t>(duration(TimeUnit::NANO), {2, 1, 2, 1},
335+
{true, false, true, true}, {2, 0, 1}, {1, 0, 1},
336+
{2, 1, 1});
332337
}
333338

334339
TEST_F(TestHashKernel, UniqueBoolean) {

0 commit comments

Comments
 (0)