Repository navigation
fix: Support deserialization of BigDecimal fields in Avro records when using the "the serde way" - #338
Merged
martin-g merged 4 commits intoNov 23, 2025
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds support for deserializing BigDecimal fields in Avro records when using serde-based deserialization (the "serde way"). Previously, attempting to deserialize a record with a BigDecimal field using apache_avro::from_value() would fail with an error about an incorrect value type.
Key Changes:
- Added
Value::BigDecimalcase handling in thedeserialize_anymethod to convert BigDecimal values to strings usingto_plain_string() - Added a new test
test_avro_3779_record_with_bg_serto verify the serde serialization/deserialization round-trip works correctly
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| avro/src/de.rs | Added Value::BigDecimal handling in the deserialize_any method to deserialize BigDecimal values as strings |
| avro/src/bigdecimal.rs | Added from_value import and a new test case to verify BigDecimal deserialization via serde works correctly |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Kriskras99
approved these changes
Nov 22, 2025
| } | ||
|
|
||
| #[test] | ||
| fn test_avro_3779_record_with_bg_ser() -> TestResult { |
Contributor
There was a problem hiding this comment.
This issue number is not relevant for this test, please use avro_rs_338 so it points to this PR
martin-g
reviewed
Nov 23, 2025
martin-g
approved these changes
Nov 23, 2025
Member
|
Thank you, @eft-prima ! |
BigDecimal fields in Avro records when using the "the serde way"BigDecimal fields in Avro records when using the "the serde way"
Closed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request adds support for the deserialization of
BigDecimalfields in Avro records when using the "the serde way".Currently, the following fails when wrapping the call to
apache_avro::from_value(value)with the errorError { details: Failed to deserialize Avro value into value: incorrect value of type: BigDecimal }.I believe this is because there is no branch for
Value::BigDecimalinfn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>.I've added one using the same via string approach that's used for
Value::Uuid.