diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java index ee21a1eeb2..6f180b1f9e 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ASTConverter.java @@ -35,7 +35,6 @@ import org.apache.calcite.rel.core.Exchange; import org.apache.calcite.rel.core.Filter; import org.apache.calcite.rel.core.Join; -import org.apache.calcite.rel.core.JoinRelType; import org.apache.calcite.rel.core.Project; import org.apache.calcite.rel.core.Sort; import org.apache.calcite.rel.core.TableFunctionScan; @@ -402,24 +401,8 @@ private QueryBlockInfo convertSource(RelNode r) throws CalciteSemanticException QueryBlockInfo right = convertSource(join.getRight()); s = new Schema(left.schema, right.schema); ASTNode cond = join.getCondition().accept(new RexVisitor(s, false, r.getCluster().getRexBuilder())); - boolean semiJoin = join.isSemiJoin(); - if (join.getRight() instanceof Join && !semiJoin) { - // should not be done for semijoin since it will change the semantics - // Invert join inputs; this is done because otherwise the SemanticAnalyzer - // methods to merge joins will not kick in - JoinRelType type; - if (join.getJoinType() == JoinRelType.LEFT) { - type = JoinRelType.RIGHT; - } else if (join.getJoinType() == JoinRelType.RIGHT) { - type = JoinRelType.LEFT; - } else { - type = join.getJoinType(); - } - ast = ASTBuilder.join(right.ast, left.ast, type, cond); - } else { - ast = ASTBuilder.join(left.ast, right.ast, join.getJoinType(), cond); - } - if (semiJoin) { + ast = ASTBuilder.join(left.ast, right.ast, join.getJoinType(), cond); + if (join.isSemiJoin()) { s = left.schema; } } else if (r instanceof Union) { diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java index fe4ecf0aba..97b8c78f4e 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/PlanModifierForASTConv.java @@ -50,7 +50,6 @@ import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveProject; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortExchange; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortLimit; -import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSemiJoin; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.jdbc.HiveJdbcConverter; import org.apache.hadoop.hive.ql.optimizer.calcite.rules.HiveRelColumnsAlignment; @@ -282,17 +281,7 @@ private static boolean validJoinParent(RelNode joinNode, RelNode parent) { boolean validParent = true; if (parent instanceof Join) { - // In Hive AST, right child of join cannot be another join, - // thus we need to introduce a project on top of it. - // But we only need the additional project if the left child - // is another join too; if it is not, ASTConverter will swap - // the join inputs, leaving the join operator on the left. - // we also do it if parent is HiveSemiJoin since ASTConverter won't - // swap inputs then - // This will help triggering multijoin recognition methods that - // are embedded in SemanticAnalyzer. - if (((Join) parent).getRight() == joinNode && - (((Join) parent).getLeft() instanceof Join || parent instanceof HiveSemiJoin) ) { + if (((Join) parent).getRight() == joinNode) { validParent = false; } } else if (parent instanceof SetOp) {