How to serialize java.math.BigDecimal in Avro?

Pythoner picture Pythoner · Jul 5, 2016 · Viewed 8.6k times · Source

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

Answer

Robert Walker picture Robert Walker · Jul 6, 2016

Avro introduced logical types in 1.7.7 (I believe) that should help you serialize decimal.

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