GH-48740: [C++] Add missing CTypeTraits for decimal types#50153
GH-48740: [C++] Add missing CTypeTraits for decimal types#50153Naurder wants to merge 2 commits into
Conversation
|
Hi @HuaHuaY and @zanmato1984, |
| /// \addtogroup type-traits | ||
| /// @{ | ||
| template <> | ||
| struct CTypeTraits<Decimal128> { |
There was a problem hiding this comment.
I think it should inherit TypeTraits<Decimal128Type> like other specialization.
There was a problem hiding this comment.
Done. Thank you very much for suggestion.
|
There are some compile errors. Please fix them. The new |
zanmato1984
left a comment
There was a problem hiding this comment.
Thanks for updating this. The current version still needs changes: CI is now failing in the C++ build, and it looks caused by the placement of the new traits.
CTypeTraits<Decimal128> and CTypeTraits<Decimal256> are defined before TypeTraits<Decimal128Type> and TypeTraits<Decimal256Type>. Since the new CTypeTraits inherit from those TypeTraits, including arrow/type_traits.h instantiates the primary TypeTraits<T> first; the later explicit specializations are then rejected as “explicit specialization ... after instantiation”.
Could you move the decimal CTypeTraits definitions after the corresponding decimal TypeTraits definitions?
Also, the linked issue is about missing decimal CTypeTraits generally, and Decimal32/64 are still missing. Please add CTypeTraits<Decimal32> and CTypeTraits<Decimal64> as well.
Could you also add lightweight compile-time coverage, for example in type_test.cc, to check all four decimal mappings? Something along these lines should be enough:
static_assert(std::is_same_v<TypeTraits<Decimal32Type>::CType, Decimal32>);
static_assert(std::is_same_v<CTypeTraits<Decimal32>::ArrowType, Decimal32Type>);
// and similarly for Decimal64, Decimal128, Decimal256
Rationale for this change
As reported in #48740, the
CTypeTraitsspecializations were missing for decimal types. This prevented generic code from correctly mapping C++ decimal types to Arrow types.What changes are included in this PR?
CTypeTraits<Decimal128>mapping toDecimal128Type.CTypeTraits<Decimal256>mapping toDecimal256Type.Are these changes tested?
Yes, via existing type traits tests in the CI pipeline.
Are there any user-facing changes?
No.
Closes #48740