cjj2010 commented on code in PR #4926:
URL: https://github.com/apache/calcite/pull/4926#discussion_r3263498569


##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -2362,6 +2362,13 @@ private RexNode convertLambda(Blackboard bb, SqlNode 
node) {
     final SqlLambdaScope scope = (SqlLambdaScope) 
validator().getLambdaScope(call);
 
     final Map<String, RexNode> nameToNodeMap = new HashMap<>();
+    // For nested lambdas, inherit the parent blackboard's nameToNodeMap so 
that
+    // the inner lambda can resolve references to outer lambda parameters.
+    // e.g., in x -> EXISTS(arr, y -> x + y = 4), the inner lambda's blackboard
+    // needs access to "X" from the outer lambda's nameToNodeMap.
+    if (bb.nameToNodeMap != null) {

Review Comment:
   > speaking of this, I suspect we should reject lambdas with the same 
parameter used twice `x -> x -> x + 1`. Please write a test about that too.
   
   I completely agree. I have added new test cases for this



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

Reply via email to