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

Creates a Decimal128Array with default precision and scale, based on an iterator of i128 values without nulls

Trait Implementations

Creates a value from an iterator. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more