-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
We already have this for logical expressions:
datafusion/datafusion/expr/src/expr.rs
Lines 2011 to 2030 in ad100fb
/// Returns true if the expression node is volatile, i.e. whether it can return | |
/// different results when evaluated multiple times with the same input. | |
/// Note: unlike [`Self::is_volatile`], this function does not consider inputs: | |
/// - `rand()` returns `true`, | |
/// - `a + rand()` returns `false` | |
pub fn is_volatile_node(&self) -> bool { | |
matches!(self, Expr::ScalarFunction(func) if func.func.signature().volatility == Volatility::Volatile) | |
} | |
/// Returns true if the expression is volatile, i.e. whether it can return different | |
/// results when evaluated multiple times with the same input. | |
/// | |
/// For example the function call `RANDOM()` is volatile as each call will | |
/// return a different value. | |
/// | |
/// See [`Volatility`] for more information. | |
pub fn is_volatile(&self) -> bool { | |
self.exists(|expr| Ok(expr.is_volatile_node())) | |
.expect("exists closure is infallible") | |
} |
We dealt with the special case of functions in #16545 but I think it would be good to implement methods for the trait itself which seems clearer and more robust
Metadata
Metadata
Assignees
Labels
No labels