[AVRO] Support of Avro logical type Decimal. - #542
Conversation
… `@Decimal` is created with logical type `decimal` and type either `bytes` (by default) or `fixed`.
…java.util.BigDecimal.
|
@MichalFoksa is this ready? If so, would need to convert from Draft to regular PR. |
|
Functionality is ready - it works. Will let you know when done. |
Sounds good, thanks! |
|
@cowtowncoder PR is ready for review. |
| */ | ||
| @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| public @interface Decimal { |
There was a problem hiding this comment.
Perhaps this should be "namespaced" as @AvroDecimal? Similar to existing @AvroNamespace.
There was a problem hiding this comment.
@Decimal renamed to @AvroDecimal.
cowtowncoder
left a comment
There was a problem hiding this comment.
Looks good, just one question/suggestion wrt naming of annotation.
|
@MichalFoksa ah yes. I did close #132, since it does seem completed. Added two others in release notes. |
Support of Avro logical type
decimal. See Logical Types - Decimal specification.@Decimalannotation instructs generator to create schema with logical type decimal in bytes Avro type. To createdecimalinfixedtype, the field has to be annotated also with@AvroFixedSize.It only works when log
Limitations:
BigDecimalfiled is annotated with@Decimal. The@Decimalannotation is ignored.BigDecimal serialization is delegated to Apache
org.apache.avro.Conversions.DecimalConversion.It validates whether value fits available schema. If not, then it throws
org.apache.avro.AvroTypeException.BigDecimal deserialization is taken from #133 . Deserialization is implemented in
AvroParserImplwhere decoding from bytes of fixed is delegated to child implementations (ApacheAvroParserImpl, respJacksonAvroParserImpl).Fixes #308 , #535.