Blizzara commented on code in PR #11234:
URL: https://github.com/apache/datafusion/pull/11234#discussion_r1664848004


##########
datafusion/substrait/src/logical_plan/consumer.rs:
##########
@@ -1125,17 +1125,45 @@ pub async fn from_substrait_rex(
                     expr::ScalarFunction::new_udf(func.to_owned(), args),
                 )))
             } else if let Ok(op) = name_to_op(fn_name) {
-                if args.len() != 2 {
+                if f.arguments.len() < 2 {
                     return not_impl_err!(
-                        "Expect two arguments for binary operator {op:?}"
+                        "Expect at least two arguments for binary operator 
{op:?}, the provided number of operators is {:?}",
+                        f.arguments.len()
                     );
                 }
 
-                Ok(Arc::new(Expr::BinaryExpr(BinaryExpr {
-                    left: Box::new(args[0].to_owned()),
-                    op,
-                    right: Box::new(args[1].to_owned()),
-                })))
+                let mut combined_expr: Option<Arc<Expr>> = None;
+
+                // Iterate through all arguments to construct the combined 
expression
+                for arg in &f.arguments {
+                    let next_expr = match &arg.arg_type {
+                        Some(ArgType::Value(val)) => {
+                            from_substrait_rex(ctx, val, input_schema, 
extensions).await?
+                        }
+                        other => {
+                            return not_impl_err!(
+                                "Invalid argument for binary expression: 
{other:?}"
+                            );
+                        }
+                    };
+
+                    combined_expr = Some(match combined_expr {

Review Comment:
   Just ooc, would it be possible (and neat) to write this as a 
[fold](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.fold)? 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to