You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/27 19:50:35 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2357: WIP: simplify_expressions no longer panics on unsupported evaluations

alamb commented on code in PR #2357:
URL: https://github.com/apache/arrow-datafusion/pull/2357#discussion_r860189248


##########
datafusion/core/src/optimizer/simplify_expressions.rs:
##########
@@ -400,9 +402,9 @@ impl<'a> ConstEvaluator<'a> {
     }
 
     /// Internal helper to evaluates an Expr
-    pub(crate) fn evaluate_to_scalar(&self, expr: Expr) -> Result<ScalarValue> {
+    pub(crate) fn evaluate_to_scalar(&self, expr: &Expr) -> Result<ScalarValue> {
         if let Expr::Literal(s) = expr {
-            return Ok(s);
+            return Ok(s.clone());

Review Comment:
   The `clone` is unfortunate -- I wonder if there is some way to pass it back. Like for example a signature such as  he following (aka return the `Expr` as the error if the evaluation doesn't work)?
   
   Maybe with some debugging messages on error (via `debug!`) would be sufficent?
   
   ```rust
       pub(crate) fn evaluate_to_scalar(&self, expr: Expr) -> std::result::Result<ScalarValue, Expr> {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org