pub enum ColumnarValue {
Array(Arc<dyn Array>),
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§
Implementations§
source§impl ColumnarValue
impl ColumnarValue
pub fn data_type(&self) -> DataType
sourcepub fn into_array(
self,
num_rows: usize
) -> Result<Arc<dyn Array>, DataFusionError>
pub fn into_array( self, num_rows: usize ) -> Result<Arc<dyn Array>, DataFusionError>
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
sourcepub fn create_null_array(num_rows: usize) -> ColumnarValue
pub fn create_null_array(num_rows: usize) -> ColumnarValue
null columnar values are implemented as a null array in order to pass batch num_rows
sourcepub fn values_to_arrays(
args: &[ColumnarValue]
) -> Result<Vec<Arc<dyn Array>>, DataFusionError>
pub fn values_to_arrays( args: &[ColumnarValue] ) -> Result<Vec<Arc<dyn Array>>, DataFusionError>
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
sourcepub fn cast_to(
&self,
cast_type: &DataType,
cast_options: Option<&CastOptions<'static>>
) -> Result<ColumnarValue, DataFusionError>
pub fn cast_to( &self, cast_type: &DataType, cast_options: Option<&CastOptions<'static>> ) -> Result<ColumnarValue, DataFusionError>
Cast’s this ColumnarValue to the specified DataType
Trait Implementations§
source§impl Clone for ColumnarValue
impl Clone for ColumnarValue
source§fn clone(&self) -> ColumnarValue
fn clone(&self) -> ColumnarValue
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for ColumnarValue
impl Debug for ColumnarValue
source§impl From<ScalarValue> for ColumnarValue
impl From<ScalarValue> for ColumnarValue
source§fn from(value: ScalarValue) -> ColumnarValue
fn from(value: ScalarValue) -> ColumnarValue
Auto Trait Implementations§
impl Freeze for ColumnarValue
impl !RefUnwindSafe for ColumnarValue
impl Send for ColumnarValue
impl Sync for ColumnarValue
impl Unpin for ColumnarValue
impl !UnwindSafe for ColumnarValue
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more