gstvg commented on code in PR #21679:
URL: https://github.com/apache/datafusion/pull/21679#discussion_r3098231788
##########
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");
+ }
+
+ expressions::lambda(
+ params,
+ create_physical_expr(body, input_dfschema, execution_props)?,
+ )
+ }
+ Expr::LambdaVariable(LambdaVariable {
+ name,
+ field,
+ spans: _,
+ }) => {
+ let index = input_dfschema.inner().index_of(name)?;
+ let schema_field = input_dfschema.field(index);
+
+ // LambdaVariable.field will be made optional as in
Expr::Placeholder
+ // and only LambdaVariable.name used, and field.name ignored,
+ // so they're not enforced to match for logical expressions
+ if field.data_type() != schema_field.data_type()
+ || field.is_nullable() != schema_field.is_nullable()
+ || field.metadata() != schema_field.metadata()
+ || field.dict_is_ordered() != schema_field.dict_is_ordered()
Review Comment:
Using `Field::eq` at
https://github.com/apache/datafusion/pull/21679/commits/94e37dbd962d43c922c8af81b82b215246085212,
thanks
##########
datafusion-examples/examples/sql_ops/frontend.rs:
##########
@@ -175,6 +179,10 @@ impl ContextProvider for MyContextProvider {
Vec::new()
}
+ fn udhof_names(&self) -> Vec<String> {
Review Comment:
https://github.com/apache/datafusion/pull/21679/commits/7f72b5b41254733039311bf50d06e8b723c2a2c2,
thanks
--
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]