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) ) { validParent = false; } } else if (parent instanceof SetOp) { validParent = false; } return validParent; }
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. // This will help triggering multijoin recognition methods that // are embedded in SemanticAnalyzer. if (((Join) parent).getRight() == joinNode && (((Join) parent).getLeft() instanceof Join) ) { validParent = false; } } else if (parent instanceof SetOp) { validParent = false; } return validParent; }
.builder(); ImmutableMap<Integer, Double> colStatMap; int rightOffSet = j.getLeft().getRowType().getFieldCount(); HiveRelMdDistinctRowCount.getDistinctRowCount(j.getLeft(), mq, ljk)); ndvCrossProduct = Math.min(mq.getRowCount(j.getLeft()), ndvCrossProduct); }else if (j instanceof HiveJoin){ ndvCrossProduct = Math.min(mq.getRowCount(j.getLeft())
public Double getSelectivity(Join j, RelMetadataQuery mq, RexNode predicate) { if (j.getJoinType().equals(JoinRelType.INNER)) { return computeInnerJoinSelectivity(j, mq, predicate); } else if (j.getJoinType().equals(JoinRelType.LEFT) || j.getJoinType().equals(JoinRelType.RIGHT)) { double left = mq.getRowCount(j.getLeft()); double right = mq.getRowCount(j.getRight()); double product = left * right; double innerJoinSelectivity = computeInnerJoinSelectivity(j, mq, predicate); if (j.getJoinType().equals(JoinRelType.LEFT)) { return Math.max(innerJoinSelectivity, left/product); } return Math.max(innerJoinSelectivity, right/product); } return 1.0; }
int nFieldsLeft = joinRel.getLeft().getRowType().getFieldList().size(); int nFieldsRight = joinRel.getRight().getRowType().getFieldList().size(); int nSysFields = joinRel.getSystemFieldList().size();
public Double getSelectivity(Join j, RelMetadataQuery mq, RexNode predicate) { if (j.getJoinType().equals(JoinRelType.INNER)) { return computeInnerJoinSelectivity(j, mq, predicate); } else if (j.getJoinType().equals(JoinRelType.LEFT) || j.getJoinType().equals(JoinRelType.RIGHT)) { double left = mq.getRowCount(j.getLeft()); double right = mq.getRowCount(j.getRight()); double product = left * right; double innerJoinSelectivity = computeInnerJoinSelectivity(j, mq, predicate); if (j.getJoinType().equals(JoinRelType.LEFT)) { return Math.max(innerJoinSelectivity, left/product); } return Math.max(innerJoinSelectivity, right/product); } return 1.0; }
int nFieldsLeft = joinRel.getLeft().getRowType().getFieldList().size(); int nFieldsRight = joinRel.getRight().getRowType().getFieldList().size(); int nSysFields = joinRel.getSystemFieldList().size();
int nullIndicatorPos) { final RelDataTypeFactory typeFactory = join.getCluster().getTypeFactory(); final RelNode left = join.getLeft(); final JoinRelType joinType = join.getJoinType();
@Override public void onMatch(RelOptRuleCall call) { final Join join = call.rel(0); final RexBuilder rexBuilder = join.getCluster().getRexBuilder(); final RexNode condition = RexUtil.pullFactors(rexBuilder, join.getCondition()); RexNode newCondition = analyzeRexNode(rexBuilder, condition); // If we could not transform anything, we bail out if (newCondition.toString().equals(condition.toString())) { return; } RelNode newNode = join.copy(join.getTraitSet(), newCondition, join.getLeft(), join.getRight(), join.getJoinType(), join.isSemiJoinDone()); call.transformTo(newNode); } }
@Override public void onMatch(RelOptRuleCall call) { final Join topJoin= call.rel(0); final Join join = call.rel(2); final Aggregate aggregate = call.rel(6); // in presence of grouping sets we can't remove sq_count_check if(aggregate.indicator) { return; } if(isAggregateWithoutGbyKeys(aggregate) || isAggWithConstantGbyKeys(aggregate, call)) { // join(left, join.getRight) RelNode newJoin = HiveJoin.getJoin(topJoin.getCluster(), join.getLeft(), topJoin.getRight(), topJoin.getCondition(), topJoin.getJoinType()); call.transformTo(newJoin); } } }
join.getLeft(), true, false);
@Override public void onMatch(RelOptRuleCall call) { final Join join = call.rel(0); RelNode lChild = join.getLeft(); RelNode rChild = join.getRight();
assert registry != null; RexBuilder rB = join.getCluster().getRexBuilder(); RelNode lChild = join.getLeft(); RelNode rChild = join.getRight();
ImmutableBitSet.range(0, join.getLeft().getRowType().getFieldCount());
final MutableRel left = toMutable(join.getLeft()); final MutableRel right = toMutable(join.getRight()); return MutableJoin.of(join.getCluster(), left, right,
assert registry != null; RexBuilder rB = join.getCluster().getRexBuilder(); RelNode lChild = join.getLeft(); RelNode rChild = join.getRight();
} else if (r instanceof Join) { Join join = (Join) r; QueryBlockInfo left = convertSource(join.getLeft()); QueryBlockInfo right = convertSource(join.getRight()); s = new Schema(left.schema, right.schema);