Description
I just started using ratatool today and am using it for CaseClass and Avro generation. I believe there's an issue in the way it handles, or fails to handle, logical types in avro.
I'm using java/scala type BigDecimal
, which in schema looks like this (newlines added by me for easier reading):
{
"name":"cost",
"type": {
"type":"bytes",
"logicalType":"decimal",
"precision":10,
"scale":2
}
}
Decimal logical type is documented here: https://avro.apache.org/docs/current/spec.html#Logical+Types
What's happening when attempting to use avroOf[MyGenericRecord]
is the type
pattern match (found in AvroGenerator.scala) hits Schema.Type.BYTES
and can generate byte[0]
.
Later, the AvroCodec, which does honor the BigDecimal logical type, attempts to convert byte[0]
into a BigInteger
(see https://github.com/apache/avro/blob/master/lang/java/avro/src/main/java/org/apache/avro/Conversions.java#L84), which fails with:
NumberFormatException("Zero length BigInteger")
I feel there's a few options which could be done independently here (I'll PR as I'm able):
- document the current limitation
- add support for common, documented logical types to ratatool. likely these can be done in independent PRs
Activity