rluvaton commented on code in PR #21896:
URL: https://github.com/apache/datafusion/pull/21896#discussion_r3156698615
##########
datafusion/physical-expr/src/higher_order_function.rs:
##########
@@ -73,15 +88,13 @@ pub struct HigherOrderFunctionExpr {
/// LiteralExpression(2)
/// ```
args: Vec<Arc<dyn PhysicalExpr>>,
- /// Positions in `args` where lambdas were top level arguments during
try_new_with_schema
- /// but may have been wrapped by tree node rewrites via with_new_children,
like:
- ///
- /// ```ignore
- /// expr.transform(|expr|
Ok(Transformed::yes(Arc::new(DebugExpr::new(expr)))))
- /// ```
- ///
- /// For example, for `array_transform([2, 3], v -> v != 2)`, this will be
`vec![1]`
- lambda_positions: Vec<usize>,
+ /// Per-arg classification, parallel to `args`. Length always equals
+ /// `args.len()`. Lambda variants carry the resolved inner [`LambdaExpr`]
+ /// so `evaluate` doesn't walk through wrapper nodes.
+ slots: Vec<ArgSlot>,
+ /// Cached value of [`HigherOrderUDF::clear_null_values`]. Avoids a virtual
+ /// call per non-lambda arg per batch.
+ clear_null_values: bool,
Review Comment:
Is it really expensive that it worth this?
##########
datafusion/expr/src/higher_order_function.rs:
##########
@@ -218,11 +218,21 @@ pub struct LambdaArgument {
/// For example, for `array_transform([2], v -> -v)`,
/// this will be the physical expression of `-v`
body: Arc<dyn PhysicalExpr>,
+ /// Cached schema built from `params`. Reused across every `evaluate` call
+ /// (and across every nested-list iteration when the lambda is called once
+ /// per outer sublist), avoiding the per-call `Schema::new` build that
+ /// includes constructing the internal name -> index map.
+ schema: Arc<Schema>,
Review Comment:
```suggestion
schema: SchemaRef,
```
--
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]