xiedeyantu commented on code in PR #4280:
URL: https://github.com/apache/calcite/pull/4280#discussion_r2037681368


##########
core/src/main/java/org/apache/calcite/rel/rules/JoinConditionOrExpansionRule.java:
##########
@@ -55,40 +62,92 @@ protected JoinConditionOrExpansionRule(Config config) {
   @Override public void onMatch(RelOptRuleCall call) {
     Join join = call.rel(0);
     RelBuilder relBuilder = call.builder();
-    List<RexNode> orConds = RelOptUtil.disjunctions(join.getCondition());
-
-    if (orConds.size() <= 1) {
-      return;
-    }
 
     RelNode converted;
     switch (join.getJoinType()) {
     case INNER:
-      converted = expandInnerJoin(join, orConds, relBuilder);
-      break;
-    case SEMI:
-      converted =
-          expandSemiOrAntiJoin(join, JoinRelType.SEMI, orConds, relBuilder);
+      converted = expandInnerJoin(join, relBuilder);
       break;
     case ANTI:
-      converted =
-          expandSemiOrAntiJoin(join, JoinRelType.ANTI, orConds, relBuilder);
+      converted = expandAntiJoin(join, relBuilder);
       break;
     case LEFT:
-      converted = expandLeftJoin(join, orConds, relBuilder);
+      converted = expandLeftOrRightJoin(join, true, relBuilder);
       break;
     case RIGHT:
-      converted = expandRightJoin(join, orConds, relBuilder);
+      converted = expandLeftOrRightJoin(join, false, relBuilder);
       break;
     case FULL:
-      converted = expandFullJoin(join, orConds, relBuilder);
+      converted = expandFullJoin(join, relBuilder);
       break;
     default:
       return;
     }
+
+    if (converted == null) {
+      return;
+    }
     call.transformTo(converted);
   }
 
+  private boolean skip(Join join) {
+    List<RexNode> orConds = RelOptUtil.disjunctions(join.getCondition());
+    return orConds.size() <= 1;
+  }
+
+  private List<RexNode> splitCond(Join join) {
+    RexBuilder builder = join.getCluster().getRexBuilder();
+    List<RexNode> conds = new ArrayList<>();
+    List<RexNode> otherConds = new ArrayList<>();
+    List<RexNode> orConds = RelOptUtil.disjunctions(join.getCondition());
+    int leftFieldCount = join.getLeft().getRowType().getFieldCount();
+
+    for (RexNode cond : orConds) {
+      if (!isUsefulCond(cond, leftFieldCount)) {

Review Comment:
   I kept the order of the join conditions and also fixed a few details you 
mentioned. Thanks so much!



-- 
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: commits-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to