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
decimallogical type, which is currently unimplemented as indicated by thetest_decimal_logical_type_not_implementedtest case. Thedecimaltype 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
decimallogical type into the corresponding ArrowDecimal128orDecimal256data types.The main changes are:
Schema Parsing (
codec.rs):make_data_typeto correctly parse thedecimallogical type from the Avro schema.Codecenum'sDecimalvariant now correctly stores the precision, scale, and optional fixed-size from the schema's attributes.Decoding Logic (
record.rs):Decoder::Decimal128andDecoder::Decimal256variants to handle decoding of decimal values from bothbytesandfixedAvro types.Are these changes tested?
This PR includes comprehensive tests to validate the new functionality:
test_decimal_logical_type_not_implementedtest 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:fixedandbytesprimitive types.Decimal128andDecimal256.Are there any user-facing changes?
N/A