Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cpp/src/arrow/type_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<TypeTraits<Decimal32Type>::CType, Decimal32>);
static_assert(std::is_same_v<CTypeTraits<Decimal32>::ArrowType, Decimal32Type>);

static_assert(std::is_same_v<TypeTraits<Decimal64Type>::CType, Decimal64>);
static_assert(std::is_same_v<CTypeTraits<Decimal64>::ArrowType, Decimal64Type>);

static_assert(std::is_same_v<TypeTraits<Decimal128Type>::CType, Decimal128>);
static_assert(std::is_same_v<CTypeTraits<Decimal128>::ArrowType, Decimal128Type>);

static_assert(std::is_same_v<TypeTraits<Decimal256Type>::CType, Decimal256>);
static_assert(std::is_same_v<CTypeTraits<Decimal256>::ArrowType, Decimal256Type>);
}

TEST(TestBinaryType, ToString) {
BinaryType t1;
BinaryType e1;
Expand Down
20 changes: 20 additions & 0 deletions cpp/src/arrow/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,26 @@ struct TypeTraits<Decimal256Type> {
constexpr static bool is_parameter_free = false;
};

template <>
struct CTypeTraits<Decimal32> : TypeTraits<Decimal32Type> {
using ArrowType = Decimal32Type;
};

template <>
struct CTypeTraits<Decimal64> : TypeTraits<Decimal64Type> {
using ArrowType = Decimal64Type;
};

template <>
struct CTypeTraits<Decimal128> : TypeTraits<Decimal128Type> {
using ArrowType = Decimal128Type;
};

template <>
struct CTypeTraits<Decimal256> : TypeTraits<Decimal256Type> {
using ArrowType = Decimal256Type;
};

template <>
struct TypeTraits<BinaryType> {
using ArrayType = BinaryArray;
Expand Down