How to serialize java.math.BigDecimal in Avro?

Avro schemas are defined using JSON. Schemes consist of primitive types (null, boolean, int, long, float, double, bytes and string) and complex types (record, enumeration, array, map, union and fixed). I want to ask which one is suitable for BigDecimal.

+8
source share
2 answers

Avro introduces boolean types in 1.7.7 (I believe), which should help you serialize decimal numbers.

https://avro.apache.org/docs/1.8.1/spec.html#Decimal

+8
source

Here is the code:

"type": [ {
    "type": "string",
    "java-class": "java.math.BigDecimal"
 } ]
+1
source

All Articles