iwanttobepowerful commented on code in PR #4382:
URL: https://github.com/apache/calcite/pull/4382#discussion_r2108268707


##########
core/src/main/java/org/apache/calcite/rel/rules/SubQueryRemoveRule.java:
##########
@@ -960,13 +1001,45 @@ private static void matchJoin(SubQueryRemoveRule rule, 
RelOptRuleCall call) {
               .union(ImmutableBitSet.range(nFields - nFieldsRight, nFields)));
       builder.project(fields);
     } else {
-      builder.push(join.getLeft());
       builder.push(join.getRight());
 
+      final RelOptUtil.Logic logic =
+          LogicVisitor.find(join.getJoinType().generatesNullsOnLeft()
+                  ? RelOptUtil.Logic.TRUE_FALSE_UNKNOWN : 
RelOptUtil.Logic.TRUE,
+              ImmutableList.of(join.getCondition()), e);
+
+      RexSubQuery subQuery = e;
+
+      if (!variablesSet.isEmpty()) {
+        // Original correlates reference joint row type, but we are about to 
create
+        // new join of original right side and correlated sub-query. Therefore 
we have
+        // to adjust correlated variables int following way:

Review Comment:
   int following way
   ->
   in following way



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