jecsand838 opened a new pull request, #7832:
URL: https://github.com/apache/arrow-rs/pull/7832

   # Which issue does this PR close?
   
   Part of https://github.com/apache/arrow-rs/issues/4886
   
   Related to https://github.com/apache/arrow-rs/pull/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 the 
`test_decimal_logical_type_not_implemented` test case. The `decimal` 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 Arrow `Decimal128` or 
`Decimal256` data types.
   
   The main changes are:
   1.  **Schema Parsing (`codec.rs`):**
       *   Implemented the logic within `make_data_type` to correctly parse the 
`decimal` logical type from the Avro schema.
       *   The `Codec` enum's `Decimal` variant now correctly stores the 
precision, scale, and optional fixed-size from the schema's attributes.
   
   2.  **Decoding Logic (`record.rs`):**
       *   Added `Decoder::Decimal128` and `Decoder::Decimal256` variants to 
handle decoding of decimal values from both `bytes` and `fixed` Avro types.
       *   The implementation correctly handles sign extension for negative 
numbers to ensure accurate representation in Arrow's decimal arrays.
   
   # Are these changes tested?
   
   This PR includes comprehensive tests to validate the new functionality:
   *   The existing `test_decimal_logical_type_not_implemented` test has been 
replaced with concrete test cases.
   *   Added unit tests in `record.rs` (`test_decimal_decoding_fixed256`, 
`test_decimal_decoding_fixed128`, `test_decimal_decoding_bytes_with_nulls`, 
etc.) to cover various scenarios, including:
       *   Decoding from Avro `fixed` and `bytes` primitive types.
       *   Handling different precisions to select between `Decimal128` and 
`Decimal256`.
       *   Correctly processing null values within decimal arrays.
   
   # Are there any user-facing changes?
   
   N/A
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to