Type Definition arrow::array::Decimal128Array
source · [−]pub type Decimal128Array = DecimalArray<Decimal128Type>;
Expand description
Decimal128Array
stores fixed width decimal numbers,
with a fixed precision and scale.
Examples
use arrow::array::{Array, DecimalArray, Decimal128Array};
use arrow::datatypes::DataType;
// Create a DecimalArray with the default precision and scale
let decimal_array: Decimal128Array = vec![
Some(8_887_000_000_i128),
None,
Some(-8_887_000_000_i128),
]
.into_iter().collect();
// set precision and scale so values are interpreted
// as `8887.000000`, `Null`, and `-8887.000000`
let decimal_array = decimal_array
.with_precision_and_scale(23, 6)
.unwrap();
assert_eq!(&DataType::Decimal128(23, 6), decimal_array.data_type());
assert_eq!(8_887_000_000_i128, decimal_array.value(0).as_i128());
assert_eq!("8887.000000", decimal_array.value_as_string(0));
assert_eq!(3, decimal_array.len());
assert_eq!(1, decimal_array.null_count());
assert_eq!(32, decimal_array.value_offset(2));
assert_eq!(16, decimal_array.value_length());
assert_eq!(23, decimal_array.precision());
assert_eq!(6, decimal_array.scale());
Implementations
sourceimpl Decimal128Array
impl Decimal128Array
sourcepub fn from_iter_values<I: IntoIterator<Item = i128>>(iter: I) -> Self
pub fn from_iter_values<I: IntoIterator<Item = i128>>(iter: I) -> Self
Creates a Decimal128Array with default precision and scale,
based on an iterator of i128
values without nulls
Trait Implementations
sourceimpl<Ptr: Into<i128>> FromIterator<Option<Ptr>> for Decimal128Array
impl<Ptr: Into<i128>> FromIterator<Option<Ptr>> for Decimal128Array
sourcefn from_iter<I: IntoIterator<Item = Option<Ptr>>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = Option<Ptr>>>(iter: I) -> Self
Creates a value from an iterator. Read more