if (origJoinRel.isSemiJoinDone()) { return; if (origJoinRel.getJoinType() != JoinRelType.INNER) { return; List<Integer> rightKeys = new ArrayList<Integer>(); RelOptUtil.splitJoinCondition( origJoinRel.getLeft(), origJoinRel.getRight(), origJoinRel.getCondition(), leftKeys, rightKeys); origJoinRel.getCluster(), origJoinRel.getLeft(), origJoinRel.getRight(), origJoinRel.getCondition(), leftKeys, rightKeys); new JoinRel( origJoinRel.getCluster(), semiJoin, origJoinRel.getRight(), origJoinRel.getCondition(), JoinRelType.INNER, Collections.<String>emptySet(), true,
public void rewriteRel(JoinRel rel) { JoinRel newRel = new JoinRel( rel.getCluster(), getNewForOldRel(rel.getLeft()), getNewForOldRel(rel.getRight()), flattenFieldAccesses(rel.getCondition()), rel.getJoinType(), rel.getVariablesStopped()); setNewForOldRel(rel, newRel); }
@Override public JoinRel copy(RelTraitSet traitSet, RexNode conditionExpr, RelNode left, RelNode right, JoinRelType joinType, boolean semiJoinDone) { assert traitSet.containsIfApplicable(Convention.NONE); return new JoinRel( getCluster(), left, right, conditionExpr, joinType, this.variablesStopped, semiJoinDone, this.systemFieldList); }
JoinRelType joinType = join.getJoinType(); switch (joinType) { case LEFT: final RexBuilder rexBuilder = join.getCluster().getRexBuilder(); final RelDataType leftRowType = join.getLeft().getRowType(); final RelDataType rightRowType = join.getRight().getRowType(); final VariableReplacer variableReplacer = new VariableReplacer(rexBuilder, leftRowType, rightRowType); final RexNode oldCondition = join.getCondition().clone(); RexNode condition = variableReplacer.go(oldCondition); new JoinRel( join.getCluster(), join.getRight(), join.getLeft(), condition, joinType, Collections.<String>emptySet(), join.isSemiJoinDone(), join.getSystemFieldList()); if (!join.getVariablesStopped().isEmpty()) { newJoin.setVariablesStopped( new HashSet<String>(join.getVariablesStopped())); newJoin, exps, join.getRowType().getFieldNames(), true);
@Override public RelNode convert(RelNode rel) { JoinRel join = (JoinRel) rel; List<RelNode> newInputs = new ArrayList<RelNode>(); for (RelNode input : join.getInputs()) { if (!(input.getConvention() instanceof EnumerableConvention)) { input = convert( input, input.getTraitSet() .replace(EnumerableConvention.INSTANCE)); } newInputs.add(input); } try { return new EnumerableJoinRel( join.getCluster(), join.getTraitSet().replace(EnumerableConvention.INSTANCE), newInputs.get(0), newInputs.get(1), join.getCondition(), join.getJoinType(), join.getVariablesStopped()); } catch (InvalidRelException e) { tracer.warning(e.toString()); return null; } } }
JoinRelType joinType = joinRel.getJoinType(); } else { rightProj = null; rightJoinChild = joinRel.getRight(); JoinRel.deriveJoinRowType( leftJoinChild.getRowType(), rightJoinChild.getRowType(), JoinRelType.INNER, joinRel.getCluster().getTypeFactory(), null, Collections.<RelDataTypeField>emptyList()); int nProjExprs = joinRel.getRowType().getFieldCount(); List<Pair<RexNode, String>> projects = new ArrayList<Pair<RexNode, String>>(); RexBuilder rexBuilder = joinRel.getCluster().getRexBuilder(); rexBuilder); topProgramBuilder.addIdentity(); topProgramBuilder.addCondition(joinRel.getCondition()); RexProgram topProgram = topProgramBuilder.getProgram(); RexProgram mergedProgram = mergedProgram.getCondition()); JoinRel newJoinRel = new JoinRel( joinRel.getCluster(),
RelNode oldLeftRel = rel.getInputs().get(0); RelNode oldRightRel = rel.getInputs().get(1); new JoinRel( rel.getCluster(), newLeftRel, newRightRel, decorrelateExpr(rel.getCondition()), rel.getJoinType(), variablesStopped); assert rel.getRowType().getFieldCount() == oldLeftFieldCount + oldRightFieldCount;
BitSet fieldsUsed, Set<RelDataTypeField> extraFields) { final RelDataType rowType = join.getRowType(); final int fieldCount = rowType.getFieldCount(); final RexNode conditionExpr = join.getCondition(); final int systemFieldCount = join.getSystemFieldList().size(); List<Mapping> inputMappings = new ArrayList<Mapping>(); List<Integer> inputExtraFieldCounts = new ArrayList<Integer>(); for (RelNode input : join.getInputs()) { final RelDataType inputRowType = input.getRowType(); final int inputFieldCount = inputRowType.getFieldCount(); join.copy(join.getTraitSet(), newConditionExpr, newInputs.get(0), newInputs.get(1), join.getJoinType(), join.isSemiJoinDone());
Set<RelDataTypeField> extraFields) final RelDataType rowType = join.getRowType(); final int fieldCount = rowType.getFieldCount(); final RexNode conditionExpr = join.getCondition(); final int systemFieldCount = join.getSystemFieldList().size(); List<Mapping> inputMappings = new ArrayList<Mapping>(); List<Integer> inputExtraFieldCounts = new ArrayList<Integer>(); for (RelNode input : join.getInputs()) { final RelDataType inputRowType = input.getRowType(); final int inputFieldCount = inputRowType.getFieldCount(); join.copy( join.getTraitSet(), newConditionExpr, newInputs.get(0),
ProjectRel projRel, int nullIndicatorPos) { RelDataTypeFactory typeFactory = joinRel.getCluster().getTypeFactory(); RelNode leftInputRel = joinRel.getLeft(); JoinRelType joinType = joinRel.getJoinType(); nullIndicatorPos, typeFactory.createTypeWithNullability( joinRel.getRowType().getFieldList().get(nullIndicatorPos) .getType(), true));
final RelNode right = call.rel( 2 ); if( !join.getVariablesStopped().isEmpty() ) left, right, join.getCondition(), leftExprs, rightExprs, final RelTraitSet traits = join.getCluster().traitSetOf( Cascading.CONVENTION ); final RexNode newCondition = createCondition( join.getCluster().getRexBuilder(), newLeft, leftKeys, newRight, rightKeys ); final CascadingJoinRel newJoin = new CascadingJoinRel( join.getCluster(), traits, convert( newLeft, traits ), convert( newRight, traits ), newCondition, join.getJoinType(), join.getVariablesStopped(), 0 );
return; if (!joinRel.getVariablesStopped().isEmpty()) { return; if (joinRel.getJoinType().generatesNullsOnLeft()) { return; if (joinRel.getJoinType().generatesNullsOnRight()) { return; new JoinRel( cluster, joinLeft, joinRight, joinRel.getCondition(), joinRel.getJoinType(), Collections.<String>emptySet()));
public void onMatch(RelOptRuleCall call) { assert matches(call); final JoinRel join = call.rel(0); RelNode right = join.getRight(); final RelNode left = join.getLeft(); final JoinInfo joinInfo = join.analyzeCondition(); final List<Correlation> correlationList = Lists.newArrayList(); if (joinInfo.leftKeys.size() > 0) { final RelOptCluster cluster = join.getCluster(); final RexBuilder rexBuilder = cluster.getRexBuilder(); RexNode condition = null; join.getCluster(), left, right, joinInfo.getRemaining(join.getCluster().getRexBuilder()), correlationList, join.getJoinType()); call.transformTo(newRel);
addOnJoinFieldRefCounts( newInputs, origJoinRel.getRowType().getFieldCount(), origJoinRel.getCondition(), joinFieldRefCountsList, newJoinFieldRefCountsMap); origJoinRel.getCluster(), newInputs, newJoinFilter, origJoinRel.getRowType(), (origJoinRel.getJoinType() == JoinRelType.FULL), newOuterJoinConds, joinTypes,
/** * Factory method that creates a join. * A subclass can override to use a different kind of join. * * @param left Left input * @param right Right input * @param condition Join condition * @param joinType Join type * @param variablesStopped Set of names of variables which are set by the * LHS and used by the RHS and are not available to * nodes above this JoinRel in the tree * @return A relational expression representing a join */ protected RelNode createJoin( RelNode left, RelNode right, RexNode condition, JoinRelType joinType, Set<String> variablesStopped) { return new JoinRel( cluster, left, right, condition, joinType, variablesStopped); }
RelNode right) RexBuilder rexBuilder = joinRel.getCluster().getRexBuilder(); JoinRelType joinType = joinRel.getJoinType(); newFilter = joinRel.getCondition();
final RelNode left = join.getLeft(); final RelNode right = join.getRight(); try { if (left instanceof TableAccessRelBase && right instanceof TableAccessRelBase) { match(left, null, right, null, join.getCluster()); final ProjectRel leftProject = (ProjectRel) left; match(leftProject.getChild(), leftProject.getMapping(), right, null, join.getCluster()); final ProjectRel rightProject = (ProjectRel) right; match(left, null, rightProject.getChild(), rightProject.getMapping(), join.getCluster()); match(leftProject.getChild(), leftProject.getMapping(), rightProject.getChild(), rightProject.getMapping(), join.getCluster());
List<Pair<JoinRelType, RexNode>> joinSpecs) JoinRelType joinType = joinRel.getJoinType(); boolean leftCombined = canCombine(left, joinType.generatesNullsOnLeft()); joinSpecs.add(Pair.of(JoinRelType.INNER, (RexNode) null)); joinSpecs.add(Pair.of(joinType, joinRel.getCondition())); break; case RIGHT: joinSpecs.add(Pair.of(joinType, joinRel.getCondition())); if (rightCombined) { copyOuterJoinInfo( left.getRowType().getFieldCount(), right.getRowType().getFieldList(), joinRel.getRowType().getFieldList()); } else { joinSpecs.add(Pair.of(JoinRelType.INNER, (RexNode) null)); left.getRowType().getFieldCount(), right.getRowType().getFieldList(), joinRel.getRowType().getFieldList()); } else { joinSpecs.add(Pair.of(JoinRelType.INNER, (RexNode) null));
public static boolean analyzeSimpleEquiJoin( JoinRel joinRel, int[] joinFieldOrdinals) { RexNode joinExp = joinRel.getCondition(); if (joinExp.getKind() != SqlKind.EQUALS) { return false; joinRel.getLeft().getRowType().getFieldCount(); RexInputRef leftFieldAccess = (RexInputRef) leftComparand; if (!(leftFieldAccess.getIndex() < leftFieldCount)) {
new JoinRel( cluster, leftInputRel, int nullIndicatorPos = joinRel.getRowType().getFieldCount() - 1; nullIndicatorPos, cluster.getTypeFactory().createTypeWithNullability( joinRel.getRowType().getFieldList() .get(nullIndicatorPos).getType(), true));