MCPcopy Create free account
hub / github.com/apache/arrow-rs / validate_decimal_precision

Method validate_decimal_precision

arrow-array/src/array/primitive_array.rs:1625–1640  ·  view source on GitHub ↗

Validates values in this array can be properly interpreted with the specified precision.

(&self, precision: u8)

Source from the content-addressed store, hash-verified

1623 /// Validates values in this array can be properly interpreted
1624 /// with the specified precision.
1625 pub fn validate_decimal_precision(&self, precision: u8) -> Result<(), ArrowError> {
1626 if precision < self.scale() as u8 {
1627 return Err(ArrowError::InvalidArgumentError(format!(
1628 "Decimal precision {precision} is less than scale {}",
1629 self.scale()
1630 )));
1631 }
1632 (0..self.len()).try_for_each(|idx| {
1633 if self.is_valid(idx) {
1634 let decimal = unsafe { self.value_unchecked(idx) };
1635 T::validate_decimal_precision(decimal, precision, self.scale())
1636 } else {
1637 Ok(())
1638 }
1639 })
1640 }
1641
1642 /// Validates the Decimal Array, if the value of slot is overflow for the specified precision, and
1643 /// will be casted to Null

Calls 5

scaleMethod · 0.45
lenMethod · 0.45
is_validMethod · 0.45
value_uncheckedMethod · 0.45