From 0678222faa86111eb3cc2e2ada341bf390231982 Mon Sep 17 00:00:00 2001 From: Naurder <48394023+Naurder@users.noreply.github.com> Date: Wed, 10 Jun 2026 22:41:58 +0200 Subject: [PATCH 1/3] GH-48740: [C++] Add missing CTypeTraits for decimal types --- cpp/src/arrow/type_traits.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cpp/src/arrow/type_traits.h b/cpp/src/arrow/type_traits.h index 1b7a02e1085a..78fb08cd3058 100644 --- a/cpp/src/arrow/type_traits.h +++ b/cpp/src/arrow/type_traits.h @@ -103,6 +103,16 @@ struct CTypeTraits {}; /// \addtogroup type-traits /// @{ +template <> +struct CTypeTraits { + using ArrowType = Decimal128Type; +}; + +template <> +struct CTypeTraits { + using ArrowType = Decimal256Type; +}; + template <> struct TypeTraits { using ArrayType = NullArray; From c1e09556ff41fe7c33ead3135a0a14076134582a Mon Sep 17 00:00:00 2001 From: Naurder <48394023+Naurder@users.noreply.github.com> Date: Thu, 11 Jun 2026 19:15:50 +0200 Subject: [PATCH 2/3] apply reviewer suggestion: inherit from TypeTraits --- cpp/src/arrow/type_traits.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/type_traits.h b/cpp/src/arrow/type_traits.h index 78fb08cd3058..900c3e05a56b 100644 --- a/cpp/src/arrow/type_traits.h +++ b/cpp/src/arrow/type_traits.h @@ -104,12 +104,12 @@ struct CTypeTraits {}; /// \addtogroup type-traits /// @{ template <> -struct CTypeTraits { +struct CTypeTraits : TypeTraits { using ArrowType = Decimal128Type; }; template <> -struct CTypeTraits { +struct CTypeTraits : TypeTraits { using ArrowType = Decimal256Type; }; From 220a94b8959e369d73ae34b7726b8041dd4b168f Mon Sep 17 00:00:00 2001 From: Naurder <48394023+Naurder@users.noreply.github.com> Date: Fri, 12 Jun 2026 18:23:04 +0200 Subject: [PATCH 3/3] Address review comments: move CTypeTraits, add Dec32/64 and tests --- cpp/src/arrow/type_test.cc | 14 ++++++++++++++ cpp/src/arrow/type_traits.h | 30 ++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/cpp/src/arrow/type_test.cc b/cpp/src/arrow/type_test.cc index 6197ad58eb40..133afbfa0c58 100644 --- a/cpp/src/arrow/type_test.cc +++ b/cpp/src/arrow/type_test.cc @@ -1493,6 +1493,20 @@ PRIMITIVE_TEST(DoubleType, double, DOUBLE, "double"); PRIMITIVE_TEST(BooleanType, bool, BOOL, "bool"); +TEST(TypesTest, DecimalTraits) { + static_assert(std::is_same_v::CType, Decimal32>); + static_assert(std::is_same_v::ArrowType, Decimal32Type>); + + static_assert(std::is_same_v::CType, Decimal64>); + static_assert(std::is_same_v::ArrowType, Decimal64Type>); + + static_assert(std::is_same_v::CType, Decimal128>); + static_assert(std::is_same_v::ArrowType, Decimal128Type>); + + static_assert(std::is_same_v::CType, Decimal256>); + static_assert(std::is_same_v::ArrowType, Decimal256Type>); +} + TEST(TestBinaryType, ToString) { BinaryType t1; BinaryType e1; diff --git a/cpp/src/arrow/type_traits.h b/cpp/src/arrow/type_traits.h index 900c3e05a56b..cbf2fcd1a22e 100644 --- a/cpp/src/arrow/type_traits.h +++ b/cpp/src/arrow/type_traits.h @@ -103,16 +103,6 @@ struct CTypeTraits {}; /// \addtogroup type-traits /// @{ -template <> -struct CTypeTraits : TypeTraits { - using ArrowType = Decimal128Type; -}; - -template <> -struct CTypeTraits : TypeTraits { - using ArrowType = Decimal256Type; -}; - template <> struct TypeTraits { using ArrayType = NullArray; @@ -367,6 +357,26 @@ struct TypeTraits { constexpr static bool is_parameter_free = false; }; +template <> +struct CTypeTraits : TypeTraits { + using ArrowType = Decimal32Type; +}; + +template <> +struct CTypeTraits : TypeTraits { + using ArrowType = Decimal64Type; +}; + +template <> +struct CTypeTraits : TypeTraits { + using ArrowType = Decimal128Type; +}; + +template <> +struct CTypeTraits : TypeTraits { + using ArrowType = Decimal256Type; +}; + template <> struct TypeTraits { using ArrayType = BinaryArray;