-
-
Notifications
You must be signed in to change notification settings - Fork 149
[AVRO] Support of Avro logical type Decimal.
#542
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
Merged
cowtowncoder
merged 12 commits into
FasterXML:2.19
from
MichalFoksa:feature/2.19/logical_type_decimal_support
Jan 4, 2025
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
52705c8
`@Decimal` annotation created. Avro schema for a field annotated with…
MichalFoksa 4dd9828
Serialization of java.math.BigDecimal to Avro `bytes` or `fixed` type…
MichalFoksa 1816c38
Parsing Avro `bytes` or `fixed` types with logical type decimal into …
MichalFoksa 213fbe3
assertEquals replaced with assertThat(actual).isEqualTo(expected);
MichalFoksa 997ad53
Assert content of serialized bytes array.
MichalFoksa 57e63b1
Serialization-deserialization tests moved into BigDecimal_serializati…
MichalFoksa 879afff
Schema creation tests moved into BigDecimal_schemaCreationTest.java
MichalFoksa ade59fc
Merge branch '2.19' into feature/2.19/logical_type_decimal_support
cowtowncoder 0e9f562
Minor streamlining
cowtowncoder 00bcdc5
@Decimal annotation renamed to @AvroDecinal
MichalFoksa bae0346
Update release notes
cowtowncoder 3be3c21
Minor javadoc/comment adds
cowtowncoder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
avro/src/main/java/com/fasterxml/jackson/dataformat/avro/annotation/Decimal.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.fasterxml.jackson.dataformat.avro.annotation; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * When generate logical types is enabled, annotation instructs the | ||
| * {@link com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaGenerator AvroSchemaGenerator} | ||
| * to declare the annotated property's logical type as "decimal" ({@link org.apache.avro.LogicalTypes.Decimal}). | ||
| * By default, the Avro type is "bytes" ({@link org.apache.avro.Schema.Type#BYTES}), unless the field is also | ||
| * annotated with {@link com.fasterxml.jackson.dataformat.avro.AvroFixedSize}, in which case the Avro type | ||
| * will be "fixed" ({@link org.apache.avro.Schema.Type#FIXED}). | ||
| * <p> | ||
| * This annotation is only used during Avro schema generation and does not affect data serialization | ||
| * or deserialization. | ||
| * | ||
| * @since 2.19 | ||
| */ | ||
| @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| public @interface Decimal { | ||
|
|
||
| /** | ||
| * Maximum precision of decimals stored in this type. | ||
| */ | ||
| int precision(); | ||
|
|
||
| /** | ||
| * Scale must be zero or a positive integer less than or equal to the precision. | ||
| */ | ||
| int scale(); | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
avro/src/test/java/com/fasterxml/jackson/dataformat/avro/BigDecimalTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@Decimalrenamed to@AvroDecimal.