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


##########
core/src/main/java/org/apache/calcite/sql2rel/CorrelateProjectExtractor.java:
##########
@@ -116,27 +134,42 @@ public CorrelateProjectExtractor(RelBuilderFactory 
factory) {
     // Transform the correlated expression from the right side to an 
expression over the left side
     builder.push(left);
 
+    ImmutableBitSet.Builder requiredColumns = ImmutableBitSet.builder();
     List<RexNode> callsWithCorrelationOverLeft = new ArrayList<>();
     for (RexNode callInRight : callsWithCorrelationInRight) {
-      
callsWithCorrelationOverLeft.add(replaceCorrelationsWithInputRef(callInRight, 
builder));
+      if (isDirectFieldAccess(callInRight, correlate.getCorrelationId())) {

Review Comment:
   Actually this is the bug that leads to the two crashes highlighted in some 
of the tests.
   You need to put the field in the list of required columns.



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