You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2019/11/06 12:05:00 UTC

[jira] [Commented] (AVRO-2429) Avro 1.9.0 fails when reading logical types other than "decimal"

    [ https://issues.apache.org/jira/browse/AVRO-2429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16968311#comment-16968311 ] 

ASF subversion and git services commented on AVRO-2429:
-------------------------------------------------------

Commit bf47ec97e0b7f5701042fac067b73b421a9177b7 in avro's branch refs/heads/master from RyanSkraba
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=bf47ec9 ]

AVRO-2429: Ignore unknown logical types in python2. (#687)

* AVRO-2429: Ignore unknown logical types in python2.

* AVRO-2429: Clean up math and unicode.

* AVRO-2429: Fix max precision formula.

If the maximum magnitude of a two's complement number of N bytes is:

max_mag(N) = 2 ** (8 * n - 1)

and the number of decimal digits required to represent M is:

decimal_digits(M) = floor(log10(M)) + 1

Then the maximum number of decimal digits that a N byte number can contain:

max_decimal_digits(N) = decimal_digits(max_mag(N))
  = floor(log10(2 ** (8 * n - 1))) + 1
  = floor( (8*n-1) * log10(2) ) + 1

If the biggest number has X decimal digits, the N bytes can represent all
numbers with X-1 decimal digits.

max_precision(N) = floor( (8*n-1) * log10(2) )

* AVRO-2429: Add unit tests for max precision.

Fix lint.


> Avro 1.9.0 fails when reading logical types other than "decimal"
> ----------------------------------------------------------------
>
>                 Key: AVRO-2429
>                 URL: https://issues.apache.org/jira/browse/AVRO-2429
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: python
>    Affects Versions: 1.9.0
>            Reporter: Chamikara Madhusanka Jayalath
>            Assignee: Ryan Skraba
>            Priority: Major
>         Attachments: uuid.avro
>
>
> [https://github.com/apache/avro/pull/82] added support for Avro "decimal" logical type but also added an assertion that results in a reader failing for other logical types. 
> [https://github.com/apache/avro/blob/master/lang/py/src/avro/schema.py#L821]
> I believe this is a regression since previously avro library used to read the underlying primitive type instead of failing.
> Can we revert the behavior for logical types that are not "decimal" by removing this assertion and reverting to the old (avro 1.8.1) behavior of returning the primitive type ?
>  
> cc: [~Fokko] [~mtth]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)