jamesstarr commented on a change in pull request #2138:
URL: https://github.com/apache/calcite/pull/2138#discussion_r496339094



##########
File path: core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
##########
@@ -2807,34 +2756,109 @@ private boolean isSubQueryNonCorrelated(RelNode subq, 
Blackboard bb) {
     return Collections.emptyList();
   }
 
-  private RexNode convertJoinCondition(Blackboard bb,
+  private void convertJoin(Blackboard bb, SqlJoin join) {
+    final SqlValidatorScope scope = validator.getJoinScope(join);
+    final Blackboard fromBlackboard = createBlackboard(scope, null, false);
+    SqlNode left = join.getLeft();
+    SqlNode right = join.getRight();
+    final SqlValidatorScope leftScope =
+        Util.first(validator.getJoinScope(left),
+            ((DelegatingScope) bb.scope).getParent());
+    final Blackboard leftBlackboard =
+        createBlackboard(leftScope, null, false);
+    final SqlValidatorScope rightScope =
+        Util.first(validator.getJoinScope(right),
+            ((DelegatingScope) bb.scope).getParent());
+    final Blackboard rightBlackboard =
+        createBlackboard(rightScope, null, false);
+    convertFrom(leftBlackboard, left);
+    final RelNode leftRel = leftBlackboard.root;
+    convertFrom(rightBlackboard, right);
+    final RelNode tempRightRel = rightBlackboard.root;
+
+    final JoinConditionType conditionType = join.getConditionType();
+    final RexNode condition;
+    final RelNode rightRel;
+    if (join.isNatural()) {
+      condition = createNaturalJoinCondition(validator.getNamespace(left),
+          validator.getNamespace(right));
+      rightRel = tempRightRel;
+    } else if (conditionType == JoinConditionType.NONE) {
+      condition = rexBuilder.makeLiteral(true);
+      rightRel = tempRightRel;

Review comment:
       Naturals does not support a switch statement, so it is if (isNatural) {} 
else {switch{...}}. Double nesting the control statements looks ugly.  But I 
can change the it to switch if you really want to.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to