Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to serialize java.math.BigDecimal in Avro?

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.

like image 646
Pythoner Avatar asked Jul 05 '16 21:07

Pythoner


2 Answers

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

like image 193
Robert Walker Avatar answered Oct 02 '22 07:10

Robert Walker


Here is the code :

"type": [ {
    "type": "string",
    "java-class": "java.math.BigDecimal"
 } ]
like image 44
rajani chauhan Avatar answered Oct 02 '22 07:10

rajani chauhan