Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-39315 Refactor PromotePrecision and CheckOverflow with decimal binary arithmetic
  3. SPARK-39316

Merge PromotePrecision and CheckOverflow into decimal binary arithmetic

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.4.0
    • 3.4.0
    • SQL
    • None

    Description

      Fix the bug of `TypeCoercion`, for example:

        SELECT CAST(1 AS DECIMAL(28, 2))
        UNION ALL
        SELECT CAST(1 AS DECIMAL(18, 2)) / CAST(1 AS DECIMAL(18, 2));
      

      The union result data type is not correct according to the formula:

      Operation Result Precision Result Scale
      e1 union e2 max(s1, s2) + max(p1-s1, p2-s2) max(s1, s2)
      -- before
      -- query schema
      decimal(28,2)
      -- query output
      1.00
      1.00
      
      -- after
      -- query schema
      decimal(38,20)
      -- query output
      1.00000000000000000000
      1.00000000000000000000
      

      Attachments

        Activity

          People

            ulysses XiDuo You
            ulysses XiDuo You
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: