Function is_constant

Source
pub fn is_constant(array: &dyn Array) -> VortexResult<Option<bool>>
Expand description

Computes whether an array has constant values. If the array’s encoding doesn’t implement the relevant VTable, it’ll try and canonicalize in order to make a determination.

An array is constant IFF at least one of the following conditions apply:

  1. It has at least one element (Note - an empty array isn’t constant).
  2. It’s encoded as a crate::arrays::ConstantArray or crate::arrays::NullArray
  3. Has an exact statistic attached to it, saying its constant.
  4. Is all invalid.
  5. Is all valid AND has minimum and maximum statistics that are equal.

If the array has some null values but is not all null, it’ll never be constant.

Returns Ok(None) if we could not determine whether the array is constant, e.g. if canonicalization is disabled and the no kernel exists for the array’s encoding.