gstvg commented on code in PR #18921:
URL: https://github.com/apache/datafusion/pull/18921#discussion_r3005982227


##########
datafusion/expr/src/expr.rs:
##########
@@ -404,6 +406,104 @@ pub enum Expr {
     OuterReferenceColumn(FieldRef, Column),
     /// Unnest expression
     Unnest(Unnest),
+    /// Call a lambda function with a set of arguments.
+    ///
+    /// For example, `array_transform([1,2,3], v -> v+1)` would be equivalent 
to:
+    ///
+    /// ```text
+    /// LambdaFunction(array_transform)
+    /// ├── args[0]: Literal([1,2,3])
+    /// └── args[1]: Lambda
+    ///     ├── params: ["v"]
+    ///     └── body: BinaryExpr(+)
+    ///         ├── LambdaVariable("v")
+    ///         └── Literal(1)
+    /// ```
+    LambdaFunction(LambdaFunction),

Review Comment:
   Hmm, definitely should be higher-order function, yes 
https://github.com/apache/datafusion/pull/18921/changes/66839d3a76c8b6a3029c97b7472e2534ce543bd3,
 thank you. Other symbols got renamed as well like `LambdaUDF` to 
`HigherOrderUDF`, `LambdaSignature` to `HigherOrderSignature`, etc
   
   For now it supports only anonymous inline functions, yes, but we can add 
support for it too. Maybe with a 
[FunctionRewrite](https://docs.rs/datafusion/latest/datafusion/logical_expr/expr_rewriter/trait.FunctionRewrite.html)
 that rewrites the scalar UDF name into an anonynomous inline function? (I 
believe it can be done out-of-tree as well)
   
   I imagine that trying to natively support names would hide the scalar udf 
call from tree traversals that may be necessary, like type coercion, and also 
somehow require the function instance access to the specific scalar udf it got 
called, like reinstancing the function with the udf, or providing the scalar 
functions map to `HigherOrderFunction` methods `invoke_with_args` and 
`return_field_from_args`, which wouldn't be as trivial as the `FunctionRewrite` 
approach



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