Enum datafusion::scalar::ScalarValue [−][src]
pub enum ScalarValue {
Show 25 variants
Boolean(Option<bool>),
Float32(Option<f32>),
Float64(Option<f64>),
Int8(Option<i8>),
Int16(Option<i16>),
Int32(Option<i32>),
Int64(Option<i64>),
UInt8(Option<u8>),
UInt16(Option<u16>),
UInt32(Option<u32>),
UInt64(Option<u64>),
Utf8(Option<String>),
LargeUtf8(Option<String>),
Binary(Option<Vec<u8>>),
LargeBinary(Option<Vec<u8>>),
List(Option<Box<Vec<ScalarValue>>>, Box<DataType>),
Date32(Option<i32>),
Date64(Option<i64>),
TimestampSecond(Option<i64>),
TimestampMillisecond(Option<i64>),
TimestampMicrosecond(Option<i64>),
TimestampNanosecond(Option<i64>),
IntervalYearMonth(Option<i32>),
IntervalDayTime(Option<i64>),
Struct(Option<Box<Vec<ScalarValue>>>, Box<Vec<Field>>),
}
Expand description
Represents a dynamically typed, nullable single value.
This is the single-valued counter-part of arrow’s Array
.
Variants
true or false value
32bit float
64bit float
signed 8bit int
signed 16bit int
signed 32bit int
signed 64bit int
unsigned 8bit int
unsigned 16bit int
unsigned 32bit int
unsigned 64bit int
utf-8 encoded string.
utf-8 encoded string representing a LargeString’s arrow type.
binary
large binary
list of nested ScalarValue (boxed to reduce size_of(ScalarValue))
Date stored as a signed 32bit int
Date stored as a signed 64bit int
Timestamp Second
Timestamp Milliseconds
Timestamp Microseconds
Timestamp Nanoseconds
Interval with YearMonth unit
Interval with DayTime unit
struct of nested ScalarValue (boxed to reduce size_of(ScalarValue))
Implementations
Getter for the DataType
of the value
Calculate arithmetic negation for a scalar value
Converts an iterator of references ScalarValue
into an ArrayRef
corresponding to those values. For example,
Returns an error if the iterator is empty or if the
ScalarValue
s are not all the same type
Example
use datafusion::scalar::ScalarValue;
use arrow::array::{ArrayRef, BooleanArray};
let scalars = vec![
ScalarValue::Boolean(Some(true)),
ScalarValue::Boolean(None),
ScalarValue::Boolean(Some(false)),
];
// Build an Array from the list of ScalarValues
let array = ScalarValue::iter_to_array(scalars.into_iter())
.unwrap();
let expected: ArrayRef = std::sync::Arc::new(
BooleanArray::from(vec![
Some(true),
None,
Some(false)
]
));
assert_eq!(&array, &expected);
Converts a scalar value into an array of size
rows.
Converts a value in array
at index
into a ScalarValue
Compares a single row of array @ index for equality with self, in an optimized fashion.
This method implements an optimized version of:
let arr_scalar = Self::try_from_array(array, index).unwrap();
arr_scalar.eq(self)
Performance note: the arrow compute kernels should be preferred over this function if at all possible as they can be vectorized and are generally much faster.
This function has a few narrow usescases such as hash table key comparisons where comparing a single row at a time is necessary.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = DataFusionError
type Error = DataFusionError
The type returned in the event of a conversion error.
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for ScalarValue
impl Send for ScalarValue
impl Sync for ScalarValue
impl Unpin for ScalarValue
impl UnwindSafe for ScalarValue
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.