From ade20b392515097211344ffdb7d41150509c3ead Mon Sep 17 00:00:00 2001 From: Nathan Chung Date: Tue, 1 Sep 2026 23:50:50 -0500 Subject: [PATCH 1/2] GH-35815: [C++] Provided dictionary support for utf8_trim What was broken: utf8_trim/utf8_ltrim/utf8_rtrim errored out on dictionary encoded string input instead of working because the functions only had kernels that registered for plain and not for dictionary so the dispatch didn't have anywhere to go. My fix was to add a small ScalarFunction subclass that unwraps a dictionary to its value type and tries again if no exact type kernel matches. I registered the three trim functions with this subclass instead of the default one. To test I added a dictionary input case to the existing TrimUTF8 test. --- .../compute/kernels/scalar_string_internal.h | 4 +-- .../compute/kernels/scalar_string_test.cc | 4 +++ .../compute/kernels/scalar_string_utf8.cc | 28 +++++++++++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/scalar_string_internal.h b/cpp/src/arrow/compute/kernels/scalar_string_internal.h index 5c621e8d53f5..4100098ef426 100644 --- a/cpp/src/arrow/compute/kernels/scalar_string_internal.h +++ b/cpp/src/arrow/compute/kernels/scalar_string_internal.h @@ -166,11 +166,11 @@ void MakeUnaryStringBatchKernel( ARROW_DCHECK_OK(registry->AddFunction(std::move(func))); } -template