shinzoxD commented on code in PR #24406:
URL: https://github.com/apache/datafusion/pull/24406#discussion_r3815214858
##########
datafusion/physical-expr/src/expressions/lambda.rs:
##########
@@ -253,6 +261,72 @@ impl TreeNodeVisitor<'_> for CollectUsedVisitor<'_> {
}
}
+/// Rewrites a lambda body so captured columns occupy `0..n_captures` and
+/// this lambda's own parameters occupy `n_captures..`. Nested lambdas are
+/// tracked on `shadow_stack` so an inner parameter that reuses a name is
+/// not remapped as if it were this lambda's param.
+struct ProjectLambdaBody<'a> {
+ column_index_map: &'a HashMap<usize, usize>,
+ param_name_to_projected: &'a HashMap<String, usize>,
+ shadow_stack: Vec<HashSet<String>>,
+}
+
+impl TreeNodeRewriter for ProjectLambdaBody<'_> {
+ type Node = Arc<dyn PhysicalExpr>;
+
+ fn f_down(&mut self, node: Self::Node) -> Result<Transformed<Self::Node>> {
Review Comment:
Addressed in 6f871bf46453567fdf90569eab49f27bf7d5395a: added
`test_nested_lambda_project_lambda_body_rebasing`, which reconstructs nested
lambdas through `ProjectLambdaBody` and asserts the `captures ++ used_params`
index layout at both levels. It covers an outer captured column (`col@2`
rebased to `col@0`), an outer parameter captured by the inner lambda (`v`), and
an inner parameter that shadows an outer name (`k`).
--
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]