-
-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AVRO] Support of Avro logical type Decimal
.
#542
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this should be "namespaced" as @AvroDecimal
? Similar to existing @AvroNamespace
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Decimal
renamed to @AvroDecimal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.@Decimal
annotation instructs generator to create schema with logical type decimal in bytes Avro type. To createdecimal
infixed
type, the field has to be annotated also with@AvroFixedSize
.It only works when log
Limitations:
BigDecimal
filed is annotated with@Decimal
. The@Decimal
annotation 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
AvroParserImpl
where decoding from bytes of fixed is delegated to child implementations (ApacheAvroParserImpl
, respJacksonAvroParserImpl
).Fixes #308 , #535.