rluvaton commented on code in PR #21679:
URL: https://github.com/apache/datafusion/pull/21679#discussion_r3094872465


##########
datafusion/physical-expr/src/planner.rs:
##########
@@ -399,6 +404,100 @@ pub fn create_physical_expr(
         Expr::Placeholder(Placeholder { id, .. }) => {
             exec_err!("Placeholder '{id}' was not provided a value for 
execution.")
         }
+        Expr::HigherOrderFunction(invocation @ HigherOrderFunction { func, 
args }) => {
+            let num_lambdas = args
+                .iter()
+                .filter(|arg| matches!(arg, Expr::Lambda(_)))
+                .count();
+
+            let mut lambda_parameters =
+                invocation.lambda_parameters(input_dfschema)?.into_iter();
+
+            if num_lambdas > lambda_parameters.len() {
+                return plan_err!(
+                    "{} lambda_parameters returned only {} values for 
{num_lambdas} lambdas",
+                    func.name(),
+                    lambda_parameters.len()
+                );
+            }
+
+            let physical_args = args
+                .iter()
+                .map(|arg| match arg {
+                    Expr::Lambda(lambda) => {
+                        let lambda_parameters = lambda_parameters
+                            .next()
+                            .ok_or_else(|| {
+                                internal_datafusion_err!(
+                                    "lambda_parameters len should have been 
checked above"
+                                )
+                            })?
+                            .into_iter()
+                            .zip(&lambda.params)
+                            .map(|(field, name)| field.with_name(name))
+                            .collect();
+
+                        let lambda_schema = DFSchema::from_unqualified_fields(
+                            lambda_parameters,
+                            HashMap::new(),
+                        )?;
+
+                        create_physical_expr(arg, &lambda_schema, 
execution_props)
+                    }
+                    _ => create_physical_expr(arg, input_dfschema, 
execution_props),
+                })
+                .collect::<Result<_>>()?;
+
+            let config_options = match execution_props.config_options.as_ref() 
{
+                Some(config_options) => Arc::clone(config_options),
+                None => Arc::new(ConfigOptions::default()),
+            };
+
+            Ok(Arc::new(HigherOrderFunctionExpr::try_new(
+                Arc::clone(func),
+                physical_args,
+                input_schema,
+                config_options,
+            )?))
+        }
+        Expr::Lambda(Lambda { params, body }) => {
+            if body.any_column_refs() {
+                return plan_err!("lambda doesn't support column capture");

Review Comment:
   please add a link to the issue that talk about column capture in lambda 
support



-- 
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