This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new a34e23783a Minor: make `Expr::volatile` infallible (#13206)
a34e23783a is described below

commit a34e23783afa99024068219d6070bd45f4d6830b
Author: Andrew Lamb <[email protected]>
AuthorDate: Fri Nov 1 12:47:25 2024 -0400

    Minor: make `Expr::volatile` infallible (#13206)
    
    * Minor: make `Expr::volatile` infallible
    
    * cmt
---
 datafusion/expr/src/expr.rs                  | 9 +++++++--
 datafusion/optimizer/src/push_down_filter.rs | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs
index bda4d7ae3d..a9c183952f 100644
--- a/datafusion/expr/src/expr.rs
+++ b/datafusion/expr/src/expr.rs
@@ -1574,8 +1574,13 @@ impl Expr {
 
     /// Returns true if the expression is volatile, i.e. whether it can return 
different
     /// results when evaluated multiple times with the same input.
-    pub fn is_volatile(&self) -> Result<bool> {
-        self.exists(|expr| Ok(expr.is_volatile_node()))
+    ///
+    /// 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())).unwrap()
     }
 
     /// Recursively find all [`Expr::Placeholder`] expressions, and
diff --git a/datafusion/optimizer/src/push_down_filter.rs 
b/datafusion/optimizer/src/push_down_filter.rs
index 1d0fc207cb..269ce29100 100644
--- a/datafusion/optimizer/src/push_down_filter.rs
+++ b/datafusion/optimizer/src/push_down_filter.rs
@@ -1200,7 +1200,7 @@ fn rewrite_projection(
 
             (qualified_name(qualifier, field.name()), expr)
         })
-        .partition(|(_, value)| value.is_volatile().unwrap_or(true));
+        .partition(|(_, value)| value.is_volatile());
 
     let mut push_predicates = vec![];
     let mut keep_predicates = vec![];


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to