Validates values in this array can be properly interpreted with the specified precision.
(&self, precision: u8)
| 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 |