Skip to content

Commit

Permalink
Validate decimal256 with i256 directly (#3025)
Browse files Browse the repository at this point in the history
* Validate decimal256 with i256

* Use from_le_bytes

* Trigger Build
  • Loading branch information
viirya committed Nov 6, 2022
1 parent 53b7f64 commit 488eff0
Show file tree
Hide file tree
Showing 2 changed files with 319 additions and 366 deletions.
8 changes: 4 additions & 4 deletions arrow-array/src/types.rs
Expand Up @@ -22,9 +22,9 @@ use crate::delta::shift_months;
use crate::OffsetSizeTrait;
use arrow_buffer::i256;
use arrow_data::decimal::{
validate_decimal256_precision_with_lt_bytes, validate_decimal_precision,
DECIMAL128_MAX_PRECISION, DECIMAL128_MAX_SCALE, DECIMAL256_MAX_PRECISION,
DECIMAL256_MAX_SCALE, DECIMAL_DEFAULT_SCALE,
validate_decimal256_precision, validate_decimal_precision, DECIMAL128_MAX_PRECISION,
DECIMAL128_MAX_SCALE, DECIMAL256_MAX_PRECISION, DECIMAL256_MAX_SCALE,
DECIMAL_DEFAULT_SCALE,
};
use arrow_schema::{ArrowError, DataType, IntervalUnit, TimeUnit};
use chrono::{Duration, NaiveDate};
Expand Down Expand Up @@ -554,7 +554,7 @@ impl DecimalType for Decimal256Type {
}

fn validate_decimal_precision(num: i256, precision: u8) -> Result<(), ArrowError> {
validate_decimal256_precision_with_lt_bytes(&num.to_le_bytes(), precision)
validate_decimal256_precision(num, precision)
}
}

Expand Down

0 comments on commit 488eff0

Please sign in to comment.