javaavrobigdecimalavro-tools

java.math.BigDecimal to Avro .avdl file


I'm having trouble writing an Avro schema for java.math.BigDecimal type, I tried the following:

  1. Based on Avro official doc, I know I need to define Logical Types myself to support BigDecimal, but that link gives example only in avsc, I'm trying to figure it out in avdl.
  2. Based on Avro doc and this example, I wrote below avdl:

`

@namespace("test")
protocol My_Protocol_v1 {

  record BigDecimal {
        @java-class("java.math.BigDecimal") string value;
  }

`

But it's not working: This IDL schema compiles fine and can generate a Java class called BigDecimal, but I cannot really use the generated BigDecimal as java.math.BigDecimal, what's wrong? or How should I do it?

Thanks a lot


Solution

  • OK, so I emailed Apache Avro dev email list and got a response from Doug Cutting (Thanks a lot Doug).

    I believe this has already been implemented but not yet released.

    It was implemented in: https://issues.apache.org/jira/browse/AVRO-1847

    This is slated to be included in the 1.8.2 release, which should soon be out.