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


##########
core/src/main/java/org/apache/calcite/sql/validate/SqlLambdaScope.java:
##########
@@ -76,9 +74,13 @@ public boolean isParameter(SqlIdentifier id) {
   }
 
   @Override public @Nullable RelDataType resolveColumn(String columnName, 
SqlNode ctx) {
-    checkArgument(parameterTypes.containsKey(columnName),
-        "column %s not found", columnName);
-    return parameterTypes.get(columnName);
+    if (parameterTypes.containsKey(columnName)) {

Review Comment:
   Do you know what happens to case sensitivity?
   I suspect parameter names are subject to the same rules as other 
identifiers, including quoting.
   Can you please write some tests using uppercase/lowercase parameter names 
and also using quoted names?
   



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



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