Add Decimal type support to arrow-avro #7832
Merged
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.
Which issue does this PR close?
Part of Add Avro Support #4886
Related to Avro codec enhancements #6965
Rationale for this change
This PR addresses a feature gap by introducing support for the Avro
decimal
logical type, which is currently unimplemented as indicated by thetest_decimal_logical_type_not_implemented
test case. Thedecimal
type is crucial for handling precise numerical data common in financial and scientific applications, making this a necessary addition for broader Avro compatibility.What changes are included in this PR?
This PR introduces the necessary changes to both parse and decode the Avro
decimal
logical type into the corresponding ArrowDecimal128
orDecimal256
data types.The main changes are:
Schema Parsing (
codec.rs
):make_data_type
to correctly parse thedecimal
logical type from the Avro schema.Codec
enum'sDecimal
variant now correctly stores the precision, scale, and optional fixed-size from the schema's attributes.Decoding Logic (
record.rs
):Decoder::Decimal128
andDecoder::Decimal256
variants to handle decoding of decimal values from bothbytes
andfixed
Avro types.Are these changes tested?
This PR includes comprehensive tests to validate the new functionality:
test_decimal_logical_type_not_implemented
test has been replaced with concrete test cases.record.rs
(test_decimal_decoding_fixed256
,test_decimal_decoding_fixed128
,test_decimal_decoding_bytes_with_nulls
, etc.) to cover various scenarios, including:fixed
andbytes
primitive types.Decimal128
andDecimal256
.Are there any user-facing changes?
N/A