Skip to content

Commit a34e237

Browse files
authored
Minor: make Expr::volatile infallible (#13206)
* Minor: make `Expr::volatile` infallible * cmt
1 parent 87f0838 commit a34e237

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

datafusion/expr/src/expr.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,8 +1574,13 @@ impl Expr {
15741574

15751575
/// Returns true if the expression is volatile, i.e. whether it can return different
15761576
/// results when evaluated multiple times with the same input.
1577-
pub fn is_volatile(&self) -> Result<bool> {
1578-
self.exists(|expr| Ok(expr.is_volatile_node()))
1577+
///
1578+
/// For example the function call `RANDOM()` is volatile as each call will
1579+
/// return a different value.
1580+
///
1581+
/// See [`Volatility`] for more information.
1582+
pub fn is_volatile(&self) -> bool {
1583+
self.exists(|expr| Ok(expr.is_volatile_node())).unwrap()
15791584
}
15801585

15811586
/// Recursively find all [`Expr::Placeholder`] expressions, and

datafusion/optimizer/src/push_down_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ fn rewrite_projection(
12001200

12011201
(qualified_name(qualifier, field.name()), expr)
12021202
})
1203-
.partition(|(_, value)| value.is_volatile().unwrap_or(true));
1203+
.partition(|(_, value)| value.is_volatile());
12041204

12051205
let mut push_predicates = vec![];
12061206
let mut keep_predicates = vec![];

0 commit comments

Comments
 (0)