Enum datafusion_expr::ColumnarValue

source ·
pub enum ColumnarValue {
    Array(ArrayRef),
    Scalar(ScalarValue),
}
Expand description

Represents the result of evaluating an expression: either a single ScalarValue or an ArrayRef.

While a ColumnarValue can always be converted into an array for convenience, it is often much more performant to provide an optimized path for scalar values.

See ColumnarValue::values_to_arrays for a function that converts multiple columnar values into arrays of the same length.

Variants§

§

Array(ArrayRef)

Array of values

§

Scalar(ScalarValue)

A single value

Implementations§

source§

impl ColumnarValue

source

pub fn data_type(&self) -> DataType

source

pub fn into_array(self, num_rows: usize) -> Result<ArrayRef>

Convert a columnar value into an Arrow ArrayRef with the specified number of rows. Self::Scalar is converted by repeating the same scalar multiple times which is not as efficient as handling the scalar directly.

See Self::values_to_arrays to convert multiple columnar values into arrays of the same length.

§Errors

Errors if self is a Scalar that fails to be converted into an array of size

source

pub fn create_null_array(num_rows: usize) -> Self

null columnar values are implemented as a null array in order to pass batch num_rows

source

pub fn values_to_arrays(args: &[ColumnarValue]) -> Result<Vec<ArrayRef>>

Converts ColumnarValues to ArrayRefs with the same length.

§Performance Note

This function expands any ScalarValue to an array. This expansion permits using a single function in terms of arrays, but it can be inefficient compared to handling the scalar value directly.

Thus, it is recommended to provide specialized implementations for scalar values if performance is a concern.

§Errors

If there are multiple array arguments that have different lengths

source

pub fn cast_to( &self, cast_type: &DataType, cast_options: Option<&CastOptions<'static>> ) -> Result<ColumnarValue>

Cast’s this ColumnarValue to the specified DataType

Trait Implementations§

source§

impl Clone for ColumnarValue

source§

fn clone(&self) -> ColumnarValue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ColumnarValue

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Arc<dyn Array>> for ColumnarValue

source§

fn from(value: ArrayRef) -> Self

Converts to this type from the input type.
source§

impl From<ScalarValue> for ColumnarValue

source§

fn from(value: ScalarValue) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.