You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Thiruvalluvan M. G. (Jira)" <ji...@apache.org> on 2019/11/09 17:39:00 UTC
[jira] [Resolved] (AVRO-2620) Max precision on decimal/fixed
LogicalType is wrong
[ https://issues.apache.org/jira/browse/AVRO-2620?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thiruvalluvan M. G. resolved AVRO-2620.
---------------------------------------
Resolution: Fixed
Merged the Pull Request. Thank you [~ryanskraba]
> Max precision on decimal/fixed LogicalType is wrong
> ---------------------------------------------------
>
> Key: AVRO-2620
> URL: https://issues.apache.org/jira/browse/AVRO-2620
> Project: Apache Avro
> Issue Type: Bug
> Components: c++, java
> Reporter: Ryan Skraba
> Assignee: Ryan Skraba
> Priority: Minor
>
> A decimal logical type with an underlying fixed bytes type is invalid if the precision is greater than can be contained in the fixed bytes. The calculation for
> [max precision|https://github.com/apache/avro/blob/a2098bd88361b5ff9298c462a2dccafbb0c2c508/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java#L262] can return a wrong value when the fixed bytes size is greater than 128.
> For a fixed size of *129*, the {{Math.pow(2, 8 * size - 1)}} part of this formula will return {{Double.INFINITY}}, and the max precision will be considered {{Long.MAX_VALUE}}. The expected value is 310 digits precision.
> We can apply the log power rule to avoid overflow, or some bit-twiddling approximation (like [java.math.BigDecimal|https://github.com/openjdk/jdk/blob/jdk8-b120/jdk/src/share/classes/java/math/BigDecimal.java#L3779]).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)