public void onMatch(RelOptRuleCall call) { LogicalFilter filter = call.rel(0); MultiJoin multiJoin = call.rel(1); MultiJoin newMultiJoin = new MultiJoin( multiJoin.getCluster(), multiJoin.getInputs(), multiJoin.getJoinFilter(), multiJoin.getRowType(), multiJoin.isFullOuterJoin(), multiJoin.getOuterJoinConditions(), multiJoin.getJoinTypes(), multiJoin.getProjFields(), multiJoin.getJoinFieldRefCountsMap(), filter.getCondition()); call.transformTo(newMultiJoin); } }
/** * Combines the post-join filters from the left and right inputs (if they * are MultiJoinRels) into a single AND'd filter. * * @param joinRel the original LogicalJoin * @param left left child of the LogicalJoin * @param right right child of the LogicalJoin * @return combined post-join filters AND'd together */ private List<RexNode> combinePostJoinFilters( Join joinRel, RelNode left, RelNode right) { final List<RexNode> filters = new ArrayList<>(); if (right instanceof MultiJoin) { final MultiJoin multiRight = (MultiJoin) right; filters.add( shiftRightFilter(joinRel, left, multiRight, multiRight.getPostJoinFilter())); } if (left instanceof MultiJoin) { filters.add(((MultiJoin) left).getPostJoinFilter()); } return filters; }
/** * Returns whether an input can be merged into a given relational expression * without changing semantics. * * @param input input into a join * @param nullGenerating true if the input is null generating * @return true if the input can be combined into a parent MultiJoin */ private boolean canCombine(RelNode input, boolean nullGenerating) { return input instanceof MultiJoin && !((MultiJoin) input).isFullOuterJoin() && !((MultiJoin) input).containsOuter() && !nullGenerating; }
@Override public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) { assert traitSet.containsIfApplicable(Convention.NONE); return new MultiJoin( getCluster(), inputs, joinFilter, rowType, isFullOuterJoin, outerJoinConditions, joinTypes, projFields, joinFieldRefCountsMap, postJoinFilter); }
public LoptMultiJoin(MultiJoin multiJoin) { this.multiJoin = multiJoin; joinFactors = ImmutableList.copyOf(multiJoin.getInputs()); nJoinFactors = joinFactors.size(); projFields = multiJoin.getProjFields(); joinFieldRefCountsMap = multiJoin.getCopyJoinFieldRefCountsMap(); Lists.newArrayList(RelOptUtil.conjunctions(multiJoin.getJoinFilter())); List<RexNode> outerJoinFilters = multiJoin.getOuterJoinConditions(); for (int i = 0; i < nJoinFactors; i++) { allJoinFilters.addAll(RelOptUtil.conjunctions(outerJoinFilters.get(i))); nTotalFields = multiJoin.getRowType().getFieldCount(); joinStart = new int[nJoinFactors]; nFieldsInJoinFactor = new int[nJoinFactors]; joinTypes = ImmutableList.copyOf(multiJoin.getJoinTypes()); List<RexNode> outerJoinConds = this.multiJoin.getOuterJoinConditions(); outerJoinFactors = new ImmutableBitSet[nJoinFactors]; for (int i = 0; i < nJoinFactors; i++) { factory = multiJoin.getCluster().getTypeFactory();
public Double getRowCount(MultiJoin rel, RelMetadataQuery mq) { if (rel.getJoinFilter().isAlwaysTrue() && RexUtil.composeConjunction(rel.getCluster().getRexBuilder(), rel.getOuterJoinConditions(), false).isAlwaysTrue()) { double rowCount = 1; for (RelNode input : rel.getInputs()) { rowCount *= mq.getRowCount(input); } return rowCount; } else { double max = 1; for (RelNode input : rel.getInputs()) { max = Math.max(max, mq.getRowCount(input)); } return max; } }
final List<Pair<JoinRelType, RexNode>> srcJoinSpecs = Pair.zip( multiJoin.getJoinTypes(), multiJoin.getOuterJoinConditions()); : src.right.accept( new RelOptUtil.RexInputConverter( multiJoin.getCluster().getRexBuilder(), srcFields, destFields, adjustments))));
@Override public void onMatch(RelOptRuleCall call) { final MultiJoin multiJoinRel = call.rel(0); final RexBuilder rexBuilder = multiJoinRel.getCluster().getRexBuilder(); final RelBuilder relBuilder = call.builder(); final RelMetadataQuery mq = call.getMetadataQuery();
public void onMatch(RelOptRuleCall call) { LogicalProject project = call.rel(0); MultiJoin multiJoin = call.rel(1); // if all inputs have their projFields set, then projection information // has already been pushed into each input boolean allSet = true; for (int i = 0; i < multiJoin.getInputs().size(); i++) { if (multiJoin.getProjFields().get(i) == null) { allSet = false; break; } } if (allSet) { return; } // create a new MultiJoin that reflects the columns in the projection // above the MultiJoin final RelBuilder relBuilder = call.builder(); MultiJoin newMultiJoin = RelOptUtil.projectMultiJoin(multiJoin, project); relBuilder.push(newMultiJoin) .project(project.getProjects(), project.getRowType().getFieldNames()); call.transformTo(relBuilder.build()); } }
final MultiJoin leftMultiJoin = (MultiJoin) left; for (int i = 0; i < left.getInputs().size(); i++) { newInputs.add(leftMultiJoin.getInput(i)); projFieldsList.add(leftMultiJoin.getProjFields().get(i)); joinFieldRefCountsList.add( leftMultiJoin.getJoinFieldRefCountsMap().get(i).toIntArray()); final MultiJoin rightMultiJoin = (MultiJoin) right; for (int i = 0; i < right.getInputs().size(); i++) { newInputs.add(rightMultiJoin.getInput(i)); projFieldsList.add( rightMultiJoin.getProjFields().get(i)); joinFieldRefCountsList.add( rightMultiJoin.getJoinFieldRefCountsMap().get(i).toIntArray());
List<RexNode> newProjExprs = new ArrayList<>(); RexBuilder rexBuilder = multiJoin.getMultiJoinRel().getCluster().getRexBuilder(); multiJoin.getMultiJoinRel().getPostJoinFilter(); if (postJoinFilter != null) { relBuilder.filter(postJoinFilter);
leftCondition = ((Join) left).getCondition(); } else { leftCondition = ((MultiJoin) left).getJoinFilter(); } else { rightCondition = shiftRightFilter(join, left, right, ((MultiJoin) right).getJoinFilter()); new MultiJoin( join.getCluster(), newInputs,
/** * Returns array of fields contained within the multi-join */ public List<RelDataTypeField> getMultiJoinFields() { return multiJoin.getRowType().getFieldList(); }
if (multiJoin.getMultiJoinRel().isFullOuterJoin()) { return;
public static JoinPredicateInfo constructJoinPredicateInfo(MultiJoin mj) { return constructJoinPredicateInfo(mj, mj.getJoinFilter()); }
new MultiJoin( origJoin.getCluster(), newInputs,
public static JoinPredicateInfo constructJoinPredicateInfo(MultiJoin mj, RexNode predicate) { final List<RelDataTypeField> systemFieldList = ImmutableList.of(); return constructJoinPredicateInfo(mj.getInputs(), systemFieldList, predicate); }
/** * @param factIdx factor for which information will be returned * * @return outer join conditions associated with the specified null * generating factor */ public RexNode getOuterJoinCond(int factIdx) { return multiJoin.getOuterJoinConditions().get(factIdx); }
public LoptMultiJoin(MultiJoin multiJoin) { this.multiJoin = multiJoin; joinFactors = ImmutableList.copyOf(multiJoin.getInputs()); nJoinFactors = joinFactors.size(); projFields = multiJoin.getProjFields(); joinFieldRefCountsMap = multiJoin.getCopyJoinFieldRefCountsMap(); Lists.newArrayList(RelOptUtil.conjunctions(multiJoin.getJoinFilter())); List<RexNode> outerJoinFilters = multiJoin.getOuterJoinConditions(); for (int i = 0; i < nJoinFactors; i++) { allJoinFilters.addAll(RelOptUtil.conjunctions(outerJoinFilters.get(i))); nTotalFields = multiJoin.getRowType().getFieldCount(); joinStart = new int[nJoinFactors]; nFieldsInJoinFactor = new int[nJoinFactors]; joinTypes = ImmutableList.copyOf(multiJoin.getJoinTypes()); List<RexNode> outerJoinConds = this.multiJoin.getOuterJoinConditions(); outerJoinFactors = new ImmutableBitSet[nJoinFactors]; for (int i = 0; i < nJoinFactors; i++) { factory = multiJoin.getCluster().getTypeFactory();
@Override public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) { assert traitSet.containsIfApplicable(Convention.NONE); return new MultiJoin( getCluster(), inputs, joinFilter, rowType, isFullOuterJoin, outerJoinConditions, joinTypes, projFields, joinFieldRefCountsMap, postJoinFilter); }