Function polars::export::arrow::compute::arithmetics::basic::checked_add_scalar
source · [−]pub fn checked_add_scalar<T>(
lhs: &PrimitiveArray<T>,
rhs: &T
) -> PrimitiveArray<T> where
T: NativeArithmetics + CheckedAdd<Output = T>,
This is supported on crate feature
compute_arithmetics
only.Expand description
Checked addition of a scalar T to a primitive array of type T. If the result from the sum overflows then the validity index for that value is changed to None
Examples
use arrow2::compute::arithmetics::basic::checked_add_scalar;
use arrow2::array::Int8Array;
let a = Int8Array::from(&[None, Some(100), None, Some(100)]);
let result = checked_add_scalar(&a, &100i8);
let expected = Int8Array::from(&[None, None, None, None]);
assert_eq!(result, expected);