Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-5019

DECIMAL V2 add/sub result type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Impala 2.0
    • Impala 2.11.0
    • Frontend
    • None

    Description

      For decimal_v2=true, we should revisit the add/sub result type. Currently, we set result scale to max(S1, S2) (potentially losing precision). Other systems (e.g. SQL Server) seem to choose either S1 or S2 depending on whether digits to the left of the decimal point would be lost. This would require changes to the backend implementation of add/sub, however.

      Currently we compute rP and rS as follows:

      rS = max(s1, s2)
      rP = max(s1, s2) + max(p1 - s1, p2 - s2) + 1
      

      We currently handle the case where rP > 38 as follows:

      if (rP > 38):
        rP = 38
        rS = min(38, rS)
      

      This basically truncates the digits to the left of the decimal point.

      The proposed result under V2 is:

      if (rP > 38):
        minS = min(rS, 6)
        rS = rS - (rP - 38)
        rS = max(minS, rS)
      

      Attachments

        Issue Links

          Activity

            People

              tarasbob Taras Bobrovytsky
              dhecht Daniel Hecht
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: