Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-11495

[RUST] [datafusion] implementation for numerical_coercion is wrong

    XMLWordPrintableJSON

Details

    Description

      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
      

      ClickHouse handled it well, maybe we should learn it from ClickHouse

       

      //代码占位符 From  https://github.com/ClickHouse/ClickHouse/blob/bd81f43ecb/src/DataTypes/NumberTraits.h
      
      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; };
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sundyli Sundy Li
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2.5h
                  2.5h