XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • Impala 4.0.0
    • Backend
    • ghx-label-8

    Description

      From discussion of IMPALA-10350, it was noted that DecimalValue<T>::ToDouble is not accurate.

      Current approach is:

       static_cast<double>(value_) / pow(10.0, scale).
      

      Inaccuracy is due to fact that only integers from −2^53 to 2^53 can be represented accurately by double precision without any loss. Hence, above approach would not work for numbers like -0.43149576573887316. For DecimalValue representing -0.43149576573887316, value_ would be -43149576573887316 and scale would be 17. As value_ < -2^53, result would not be accurate.

      Hence through discussion in IMPALA-10350, we propose to use thirdparty library https://github.com/lemire/fast_double_parser, which handles above scenario in a performant manner. Library's internal representation of Decimal is similar to the Impala's DecimalValue and function compute_float_64 can be used for the conversion.

      Attachments

        Activity

          People

            amargoor Amogh Margoor
            amargoor Amogh Margoor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: