Skip to content

Add DecimalArray type and width conversion methods - #183

Merged
pbower merged 1 commit into
feature/decimalfrom
MA-EPC86-DECIMAL-TSK382-CONVERSIONS
Aug 31, 2026
Merged

Add DecimalArray type and width conversion methods#183
pbower merged 1 commit into
feature/decimalfrom
MA-EPC86-DECIMAL-TSK382-CONVERSIONS

Conversation

@pbower

@pbower pbower commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds .to_float64_array(), .to_float32_array(), .to_int64_array(), .to_int32_array(), .to_uint64_array(), .to_uint32_array() on DecimalArray
  • Adds ::from_integer_array() for integer-to-decimal conversion with scale multiplication
  • Adds .rescale() for shifting decimal scale with overflow detection
  • Adds widening methods (to_dec64(), to_dec128()) and narrowing methods (to_dec32(), to_dec64()) with overflow checking
  • 40+ tests covering all conversion paths, edge cases, null propagation

Test plan

  • cargo test --features decimal passes (816 tests)
  • cargo test without decimal passes (no regression)

Conversion methods on DecimalArray<T: Integer>:
- to_float64_array, to_float32_array: raw / 10^scale, null mask preserved
- to_int64_array, to_int32_array: truncating division, overflow error
- to_uint64_array, to_uint32_array: truncating division, overflow/negative error
- from_integer_array: multiply by 10^scale, overflow error
- rescale: adjust scale up (multiply) or down (truncate), overflow error

Width conversion methods:
- DecimalArray<i32>::to_dec64, to_dec128 (widening, lossless)
- DecimalArray<i64>::to_dec128 (widening), to_dec32 (narrowing, overflow error)
- DecimalArray<i128>::to_dec64, to_dec32 (narrowing, overflow error)

Tests cover all conversion paths, null propagation, overflow detection,
truncation behaviour, roundtrips, and empty arrays.
@pbower
pbower force-pushed the MA-EPC86-DECIMAL-TSK382-CONVERSIONS branch from b42286b to e78f805 Compare August 31, 2026 06:48
@pbower pbower changed the title Add DecimalArray type and width conversion methods (TSK382) Add DecimalArray type and width conversion methods Aug 31, 2026
@pbower
pbower merged commit b2570e3 into feature/decimal Aug 31, 2026
14 of 17 checks passed
@pbower
pbower deleted the MA-EPC86-DECIMAL-TSK382-CONVERSIONS branch August 31, 2026 06:49
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant