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; }
final RelNode newRightInput = dispatchAlign(rel.getRight(), propagateCollationsRight.build());
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 nFieldsRight = joinRel.getRight().getRowType().getFieldList().size(); int nSysFields = joinRel.getSystemFieldList().size(); ImmutableBitSet rightFieldsBitSet = ImmutableBitSet.range(nSysFields + nFieldsLeft,
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 nFieldsRight = joinRel.getRight().getRowType().getFieldList().size(); int nSysFields = joinRel.getSystemFieldList().size(); ImmutableBitSet rightFieldsBitSet = ImmutableBitSet.range(nSysFields + nFieldsLeft,
this.isSemiJoin = isSemiJoin; nFieldsLeft = joinRel.getLeft().getRowType().getFieldList().size(); nFieldsRight = joinRel.getRight().getRowType().getFieldList().size(); nSysFields = joinRel.getSystemFieldList().size(); leftFieldsBitSet = ImmutableBitSet.range(nSysFields,
private Project swapInputs(Join join, Project topProject, RelBuilder builder) { RexBuilder rexBuilder = join.getCluster().getRexBuilder(); int rightInputSize = join.getRight().getRowType().getFieldCount(); int leftInputSize = join.getLeft().getRowType().getFieldCount(); List<RelDataTypeField> joinFields = join.getRowType().getFieldList(); Join swappedJoin = (Join)builder.push(join.getRight()).push(join.getLeft()).join(join.getJoinType(), newJoinCond).build();
@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); } } }
RelNode rightProjRel = pushProject.createProjectRefsAndExprs( join.getRight(), true, true);
final Join join = call.rel(0); RelNode lChild = join.getLeft(); RelNode rChild = join.getRight();
if (null != leftChild && leftChild.equalsIgnoreCase(getTblAlias(((Join)rel).getRight()))) {
RexBuilder rB = join.getCluster().getRexBuilder(); RelNode lChild = join.getLeft(); RelNode rChild = join.getRight();
Join join = (Join) r; QueryBlockInfo left = convertSource(join.getLeft()); 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 instanceof SemiJoin; if (join.getRight() instanceof Join && !semiJoin) {
final Join join = (Join) rel; final MutableRel left = toMutable(join.getLeft()); final MutableRel right = toMutable(join.getRight()); return MutableJoin.of(join.getCluster(), left, right, join.getCondition(), join.getJoinType(), join.getVariablesSet());
RexBuilder rB = join.getCluster().getRexBuilder(); RelNode lChild = join.getLeft(); RelNode rChild = join.getRight();