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

agrove pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion-comet.git


The following commit(s) were added to refs/heads/main by this push:
     new 77d580e  chore: Remove some calls to unwrap when calling create_expr 
in planner.rs (#269)
77d580e is described below

commit 77d580eb01e32039837e799634c4c5112554f4d7
Author: Andy Grove <[email protected]>
AuthorDate: Mon Apr 15 19:49:04 2024 -0600

    chore: Remove some calls to unwrap when calling create_expr in planner.rs 
(#269)
    
    * Remove some unwraps when calling create_expr
    
    * simplify code
---
 core/src/execution/datafusion/planner.rs | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/core/src/execution/datafusion/planner.rs 
b/core/src/execution/datafusion/planner.rs
index e53ebe7..052ecc4 100644
--- a/core/src/execution/datafusion/planner.rs
+++ b/core/src/execution/datafusion/planner.rs
@@ -489,14 +489,19 @@ impl PhysicalPlanner {
                 let when_then_pairs = case_when
                     .when
                     .iter()
-                    .map(|x| self.create_expr(x, 
input_schema.clone()).unwrap())
+                    .map(|x| self.create_expr(x, input_schema.clone()))
                     .zip(
                         case_when
                             .then
                             .iter()
-                            .map(|then| self.create_expr(then, 
input_schema.clone()).unwrap()),
+                            .map(|then| self.create_expr(then, 
input_schema.clone())),
                     )
-                    .collect::<Vec<_>>();
+                    .try_fold(Vec::new(), |mut acc, (a, b)| {
+                        acc.push((a?, b?));
+                        Ok::<Vec<(Arc<dyn PhysicalExpr>, Arc<dyn 
PhysicalExpr>)>, ExecutionError>(
+                            acc,
+                        )
+                    })?;
 
                 let else_phy_expr = match &case_when.else_expr {
                     None => None,
@@ -516,8 +521,8 @@ impl PhysicalPlanner {
                 let list = expr
                     .lists
                     .iter()
-                    .map(|x| self.create_expr(x, 
input_schema.clone()).unwrap())
-                    .collect::<Vec<_>>();
+                    .map(|x| self.create_expr(x, input_schema.clone()))
+                    .collect::<Result<Vec<_>, _>>()?;
 
                 // if schema contains any dictionary type, we should use 
InListExpr instead of
                 // in_list as it doesn't handle value being dictionary type 
correctly
@@ -1221,14 +1226,14 @@ impl PhysicalPlanner {
         let args = expr
             .args
             .iter()
-            .map(|x| self.create_expr(x, input_schema.clone()).unwrap())
-            .collect::<Vec<_>>();
+            .map(|x| self.create_expr(x, input_schema.clone()))
+            .collect::<Result<Vec<_>, _>>()?;
 
         let fun_name = &expr.func;
         let input_expr_types = args
             .iter()
-            .map(|x| x.data_type(input_schema.as_ref()).unwrap())
-            .collect::<Vec<_>>();
+            .map(|x| x.data_type(input_schema.as_ref()))
+            .collect::<Result<Vec<_>, _>>()?;
         let data_type = match expr.return_type.as_ref().map(to_arrow_datatype) 
{
             Some(t) => t,
             None => {

Reply via email to