[
https://issues.apache.org/jira/browse/AVRO-3331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17485135#comment-17485135
]
Thomas Schilling commented on AVRO-3331:
----------------------------------------
Well, the way I understand the Avro spec, maybe the library shouldn't have its
own type. Decimal is just an "overlay" of an existing type (e.g., i32, i64,
Vec<u8>). So maybe just
{code:java}
struct Decimal<T> {
scale: u8,
data: T ,
}{code}
Not sure how that changes the ergonomics, though.
My current goal is to convert this to Arrow's decimal type which is an `i128`
and the precision+scale info is in the schema (the Rust arrow lib doesn't
support `i256` at this time).
> Rust: Cannot extract Decimal value
> ----------------------------------
>
> Key: AVRO-3331
> URL: https://issues.apache.org/jira/browse/AVRO-3331
> Project: Apache Avro
> Issue Type: Bug
> Components: rust
> Reporter: Thomas Schilling
> Assignee: Martin Tzvetanov Grigorov
> Priority: Major
>
> The [Decimal|https://docs.rs/avro-rs/latest/avro_rs/struct.Decimal.html] type
> (as of 0.13) doesn't have any methods or trait implementations that allow
> users to extract the value. The only workaround I could think of would be to
> parse the output of the `Debug` implementation. But that's clearly very
> inefficient and fragile.
> The (unreleased?) version 0.14 also seems to have the same issue
> ([source|https://github.com/apache/avro/blob/master/lang/rust/src/decimal.rs]).
> It might just be enough to make the {{to_vec }}method public and specify how
> to interpret the result vector.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)