You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Ryan Skraba (Jira)" <ji...@apache.org> on 2021/06/17 13:21:00 UTC

[jira] [Commented] (AVRO-3160) Decimal logical type for strings

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

Ryan Skraba commented on AVRO-3160:
-----------------------------------

Hello -- I'm not sure this is a good idea, but there should be a reasonable work-around or alternative fix!

We were on Avro 1.7.7 for a long time, before logical types, and using the "Stringable" representation of BigDecimal. It was STRING in the serialization but BigDecimal in memory.  Switching to the FIXED representation with Avro 1.8.x was a significant improvement in our jobs and helped catch some subtle errors, so I think it's the right underlying primitive.

If you want a datum to be BigDecimal in Java but String in PHP, you might be able to reuse the Stringable-like logic -- I'd have to look up how we did this.

I'm unsure of where the PHP language SDK is with respect to logical types, but it seems to me that the right thing to do would be to have the PHP library correctly convert the decimal logical type into something appropriate for the language (as opposed to changing the spec and binary representation).

Thanks for reaching out to me specifically, this is just my opinion and doesn't have any more weight than anyone else's! :D 

> Decimal logical type for strings
> --------------------------------
>
>                 Key: AVRO-3160
>                 URL: https://issues.apache.org/jira/browse/AVRO-3160
>             Project: Apache Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Artur Kalimullin
>            Priority: Major
>
> Currently in avro there is just one way to represent BigDecimal: using bytes type with decimal logical type.
> Unfortunately, it's not really convenient to use in non-java environments (we currently have services in java and PHP that are communicating using avro).
> As an alternative, string could be used to represent decimal number without loosing precision and that's how we are doing it now. I propose to add logical type decimal to the type string to be able to use BigDecimal directly without converting it on client side.
> I could create a PR for that but wanted to know your opinion first about it, would you consider merging it? (I guess that's a question to [~rskraba])



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