pub enum ColumnarValue {
Array(Arc<dyn Array>),
Scalar(ScalarValue),
}Expand description
The result of evaluating an expression.
ColumnarValue::Scalar represents a single value repeated any number of
times. This is an important performance optimization for handling values
that do not change across rows.
ColumnarValue::Array represents a column of data, stored as an Arrow
ArrayRef
A slice of ColumnarValues logically represents a table, with each column
having the same number of rows. This means that all Arrays are the same
length.
§Example
A ColumnarValue::Array with an array of 5 elements and a
ColumnarValue::Scalar with the value 100
┌──────────────┐
│ ┌──────────┐ │
│ │ "A" │ │
│ ├──────────┤ │
│ │ "B" │ │
│ ├──────────┤ │
│ │ "C" │ │
│ ├──────────┤ │
│ │ "D" │ │ ┌──────────────┐
│ ├──────────┤ │ │ ┌──────────┐ │
│ │ "E" │ │ │ │ 100 │ │
│ └──────────┘ │ │ └──────────┘ │
└──────────────┘ └──────────────┘
ColumnarValue:: ColumnarValue::
Array ScalarLogically represents the following table:
| Column 1 | Column 2 |
|---|---|
| A | 100 |
| B | 100 |
| C | 100 |
| D | 100 |
| E | 100 |
§Performance Notes
When implementing functions or operators, it is important to consider the performance implications of handling scalar values.
Because all functions must handle ArrayRef, it is
convenient to convert ColumnarValue::Scalars using
Self::into_array. For example, ColumnarValue::values_to_arrays
converts multiple columnar values into arrays of the same length.
However, it is often much more performant to provide a different, implementation that handles scalar values differently
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 to_array(
&self,
num_rows: usize,
) -> Result<Arc<dyn Array>, DataFusionError>
pub fn to_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 Display for ColumnarValue
impl Display 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> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo* type which aligns Self to ALIGNMENT.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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
Source§fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
Source§fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped except that the function takes &Self
Useful for functions that take &Self instead of Self. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped, except that the function takes &mut Self.
Useful for functions that take &mut Self instead of Self.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef,
using the turbofish .as_ref_::<_>() syntax. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.