benwang li created ARROW-11495: ---------------------------------- Summary: [RUST] implementation for numerical_coercion is wrong Key: ARROW-11495 URL: https://issues.apache.org/jira/browse/ARROW-11495 Project: Apache Arrow Issue Type: Bug Reporter: benwang li
Currently `numerical_coercion` did not take consideration for integer overflow, such as ``` UIn8 + UIn8 should be UInt16, but now it's UInt8 UInt16 * UInt16 should be UInt64, but now it's UInt16 ``` Maybe we should learn from ClickHouse ``` template <bool is_signed, bool is_floating, size_t size> struct Construct { usingType=Error; }; template <> struct Construct<false, false, 1> \{ using Type = UInt8; }; template <> struct Construct<false, false, 2> \{ using Type = UInt16; }; template <> struct Construct<false, false, 4> \{ using Type = UInt32; }; template <> struct Construct<false, false, 8> \{ using Type = UInt64; }; template <> struct Construct<false, false, 16> \{ using Type = UInt256; }; /// TODO: we cannot use our UInt128 here template <> struct Construct<false, false, 32> \{ using Type = UInt256; }; template <> struct Construct<false, true, 1> \{ using Type = Float32; }; template <> struct Construct<false, true, 2> \{ using Type = Float32; }; template <> struct Construct<false, true, 4> \{ using Type = Float32; }; template <> struct Construct<false, true, 8> \{ using Type = Float64; }; template <> struct Construct<true, false, 1> \{ using Type = Int8; }; template <> struct Construct<true, false, 2> \{ using Type = Int16; }; template <> struct Construct<true, false, 4> \{ using Type = Int32; }; template <> struct Construct<true, false, 8> \{ using Type = Int64; }; template <> struct Construct<true, false, 16> \{ using Type = Int128; }; template <> struct Construct<true, false, 32> \{ using Type = Int256; }; template <> struct Construct<true, true, 1> \{ using Type = Float32; }; template <> struct Construct<true, true, 2> \{ using Type = Float32; }; template <> struct Construct<true, true, 4> \{ using Type = Float32; }; template <> struct Construct<true, true, 8> \{ using Type = Float64; }; ``` -- This message was sent by Atlassian Jira (v8.3.4#803005)