Wire DecimalArray into NumericArray, Array, Scalar with From impls - #182
Merged
Conversation
…m impls and tests (#182) Phase 2 of EPC86. Adds Decimal32/64/128 variants gated behind the `decimal` feature flag to NumericArray, Array, and Scalar enums. Cascades match arms across all dispatch sites, adds typed accessors (dec32/try_dec32, dec64/try_dec64, dec128/try_dec128), widening conversions between decimal widths, and liberal From impls for DecimalArray -> NumericArray -> Array.
pbower
commented
Aug 31, 2026
| NumericArray::Decimal32(_) | NumericArray::Decimal64(_) | NumericArray::Decimal128(_) => { | ||
| Err(MinarrowError::TypeError { | ||
| from: "DecimalArray", | ||
| to: "IntegerArray<i32>", |
| Err(MinarrowError::TypeError { | ||
| from: "DecimalArray", | ||
| to: "IntegerArray<i64>", | ||
| message: Some("decimal-to-integer conversion requires explicit .to_int64_array()".to_string()), |
| Err(MinarrowError::TypeError { | ||
| from: "DecimalArray", | ||
| to: "IntegerArray<u32>", | ||
| message: Some("decimal-to-integer conversion requires explicit .to_uint32_array()".to_string()), |
| Err(MinarrowError::TypeError { | ||
| from: "DecimalArray", | ||
| to: "IntegerArray<u64>", | ||
| message: Some("decimal-to-integer conversion requires explicit .to_uint64_array()".to_string()), |
| NumericArray::Decimal32(_) | NumericArray::Decimal64(_) | NumericArray::Decimal128(_) => { | ||
| Err(MinarrowError::TypeError { | ||
| from: "DecimalArray", | ||
| to: "FloatArray<f32>", |
| NumericArray::Decimal32(_) | NumericArray::Decimal64(_) | NumericArray::Decimal128(_) => { | ||
| Err(MinarrowError::TypeError { | ||
| from: "DecimalArray", | ||
| to: "BooleanArray<u8>", |
Collaborator
Author
There was a problem hiding this comment.
Clearly inconsistent.
| #[cfg(feature = "decimal")] | ||
| NumericArray::Decimal32(_) | NumericArray::Decimal64(_) | NumericArray::Decimal128(_) => { | ||
| Err(MinarrowError::TypeError { | ||
| from: "DecimalArray", |
The try_i32/i64/u32/u64/f32/f64/bool/str methods and cow_into_f64 previously returned errors for decimal variants. Now they perform scale-aware conversions consistent with every other numeric type.
pbower
added a commit
that referenced
this pull request
Aug 31, 2026
* Add DecimalArray foundation and i128 trait impls (#181) * Add Decimal32, Decimal64, Decimal128 variants to ArrowType (#180) * Wire DecimalArray into NumericArray, Array, Scalar with From impls (#182) * Wire DecimalArray into NumericArray, Array, and Scalar enums with From impls and tests (#182) * Implement decimal conversion arms in NumericArray try_ accessors * Add decimal FFI import/export with arrow-rs and Polars round-trips (#186) * Add decimal FFI import/export with arrow-rs and Polars round-trips * Integrate DecimalArray into Value, ArrayV, NumericArrayV, SuperArray, SuperArrayV, and Consolidate (#187) * Add decimal broadcast dispatch and scale-aware print formatting (#184) * Add decimal arithmetic kernels with checked overflow and auto-promotion + fix null mask drop on broadcasting (#185) * Add decimal arithmetic kernels with checked overflow and auto-promotion * Propagate null mask through broadcast for all array types * Add DecimalArray type conversions and width conversion methods (#183) * Add decimal support to pyo3 and minarrow-py Python bridges (#188) * Add Decimal32 and Decimal64 round-trip tests for arrow-rs * Add decimal support to pyo3 and minarrow-py Python bridges * Make precision and scale report values for all numeric types
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.
Summary
Decimal32,Decimal64,Decimal128variants toNumericArraywith match arms across all 12 dispatch methodsdec32()/try_dec32(),dec64()/try_dec64(),dec128()/try_dec128()accessors with cross-width wideningScalar::Decimal32/64/128variants with scale-aware Displayarrow_type()on DecimalArray (deferred from TSK375)Test plan
cargo test --features decimalpasses (775 tests)cargo testwithout decimal passes (680 tests, no regression)cargo test --all-featurespasses (1,672 tests)cargo check --all-featuresclean