You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Amogh Margoor (Jira)" <ji...@apache.org> on 2021/05/03 09:00:00 UTC
[jira] [Resolved] (IMPALA-10654) Improve the precision of
DecimalValue::ToDouble
[ https://issues.apache.org/jira/browse/IMPALA-10654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Amogh Margoor resolved IMPALA-10654.
------------------------------------
Resolution: Fixed
Resolving this JIRA as the patch submitted for this fixes this issue.
> Improve the precision of DecimalValue<T>::ToDouble
> --------------------------------------------------
>
> Key: IMPALA-10654
> URL: https://issues.apache.org/jira/browse/IMPALA-10654
> Project: IMPALA
> Issue Type: Sub-task
> Components: Backend
> Reporter: Amogh Margoor
> Assignee: Amogh Margoor
> Priority: Major
> Labels: ramp-up
>
> From discussion of IMPALA-10350, it was noted that [DecimalValue<T>::ToDouble|https://github.com/apache/impala/blob/b28da054f3595bb92873433211438306fc22fbc7/be/src/runtime/decimal-value.inline.h#L725] is not accurate.
> Current approach is:
> {code:java}
> static_cast<double>(value_) / pow(10.0, scale).
> {code}
> 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|https://github.com/lemire/fast_double_parser/blob/e4f6319bfa9cbc829f7f99ae88c1d2fb205c15e8/include/fast_double_parser.h#L232] can be used for the conversion.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org