kosiew commented on code in PR #24406:
URL: https://github.com/apache/datafusion/pull/24406#discussion_r3813619737


##########
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:
   Could we add a focused nested-lambda rebasing assertion here? It would be 
useful to cover an outer captured column, an outer parameter captured by the 
inner lambda, and an inner parameter that shadows an outer name. The existing 
shadowing test checks `used_param_indices`, but it doesn't verify the new 
`ProjectLambdaBody` index layout across both reconstruction levels.



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