pub enum Volatility {
Immutable,
Stable,
Volatile,
}
Expand description
How a function’s output changes with respect to a fixed input
The volatility of a function determines eligibility for certain optimizations. You should always define your function to have the strictest possible volatility to maximize performance and avoid unexpected results.
Variants§
Immutable
Always returns the same output when given the same input.
DataFusion will inline immutable functions during planning.
For example, the abs
function is immutable, so abs(-1)
will be
evaluated and replaced with 1
during planning rather than invoking
the function at runtime.
Stable
May return different values given the same input across different queries but must return the same value for a given input within a query.
For example, the now()
function is stable, because the query select col1, now() from t1
, will return different results each time it is run,
but within the same query, the output of the now()
function has the
same value for each output row.
DataFusion will inline Stable
functions when possible. For example,
Stable
functions are inlined when planning a query for execution, but
not in View definitions or prepared statements.
Volatile
May change the return value from evaluation to evaluation.
Multiple invocations of a volatile function may return different results
when used in the same query on different rows. An example of this is the
random()
function.
DataFusion can not evaluate such functions during planning or push these
predicates into scans. In the query select col1, random() from t1
,
random()
function will be evaluated for each output row, resulting in
a unique random value for each row.
Trait Implementations§
Source§impl Clone for Volatility
impl Clone for Volatility
Source§fn clone(&self) -> Volatility
fn clone(&self) -> Volatility
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Volatility
impl Debug for Volatility
Source§impl Hash for Volatility
impl Hash for Volatility
Source§impl Ord for Volatility
impl Ord for Volatility
Source§fn cmp(&self, other: &Volatility) -> Ordering
fn cmp(&self, other: &Volatility) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for Volatility
impl PartialEq for Volatility
Source§impl PartialOrd for Volatility
impl PartialOrd for Volatility
impl Copy for Volatility
impl Eq for Volatility
impl StructuralPartialEq for Volatility
Auto Trait Implementations§
impl Freeze for Volatility
impl RefUnwindSafe for Volatility
impl Send for Volatility
impl Sync for Volatility
impl Unpin for Volatility
impl UnwindSafe for Volatility
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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