You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(spec): replace rust_decimal with fastnum for 38-digit precision (#2063)
## Summary
Replace rust_decimal with fastnum::D128 to support 38-digit decimal
precision as required by the Iceberg spec, addressing issue #669.
## Changes
- Add `crates/iceberg/src/spec/values/decimal_utils.rs` with:
- Compatibility layer providing rust_decimal-like API using
fastnum::D128
- `decimal_from_i128_with_scale()`, `decimal_mantissa()`,
`decimal_scale()` helpers
- `i128_from_be_bytes()` / `i128_to_be_bytes_min()` for binary
serialization
- Unit tests for all helper functions including 38-digit precision
validation
- Update `Cargo.toml` (workspace and iceberg crate):
- Add fastnum dependency with std and serde features
- Remove rust_decimal, num-bigint, num-traits dependencies
- Update `crates/iceberg/src/spec/values/datum.rs`:
- Replace rust_decimal imports with decimal_utils
- Update `from_bytes()` and `to_bytes()` for new decimal API
- Update `decimal_with_precision()` validation
- Update `crates/iceberg/src/spec/values/literal.rs`:
- Update JSON serialization/deserialization for decimals
- Update `crates/iceberg/src/transform/bucket.rs` and `truncate.rs`:
- Update decimal transform implementations
- Update `crates/iceberg/src/arrow/schema.rs` and `parquet_writer.rs`:
- Update Arrow/Parquet decimal statistics handling
- Replace `BigInt` byte conversions with helper functions
- Update `.cargo/audit.toml`:
- Remove RUSTSEC-2024-0399 ignore (rust_decimal vulnerability no longer
applies)
## Notes
fastnum::D128 provides exactly 38-digit precision with stack-based
storage (no heap allocation), meeting the Iceberg spec requirement that
rust_decimal (28-digit max) could not satisfy.
The decimal_utils module abstracts the API differences between
rust_decimal and fastnum, making the migration transparent to the rest
of the codebase.
Closes#669
0 commit comments