Java Code Examples for org.apache.calcite.rel.core.JoinRelType#isOuterJoin()
The following examples show how to use
org.apache.calcite.rel.core.JoinRelType#isOuterJoin() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlinkJoinToMultiJoinRule.java From flink with Apache License 2.0 | 5 votes |
private boolean containsOuter(MultiJoin multiJoin) { for (JoinRelType joinType : multiJoin.getJoinTypes()) { if (joinType.isOuterJoin()) { return true; } } return false; }
Example 2
Source File: MultiJoin.java From calcite with Apache License 2.0 | 5 votes |
boolean containsOuter() { for (JoinRelType joinType : joinTypes) { if (joinType.isOuterJoin()) { return true; } } return false; }
Example 3
Source File: SubstitutionVisitor.java From calcite with Apache License 2.0 | 4 votes |
@Override protected UnifyResult apply(UnifyRuleCall call) { final MutableJoin query = (MutableJoin) call.query; final MutableRel qInput0 = query.getLeft(); final MutableCalc qInput1 = (MutableCalc) query.getRight(); final Pair<RexNode, List<RexNode>> qInput1Explained = explainCalc(qInput1); final RexNode qInput1Cond = qInput1Explained.left; final List<RexNode> qInput1Projs = qInput1Explained.right; final MutableJoin target = (MutableJoin) call.target; final RexBuilder rexBuilder = call.getCluster().getRexBuilder(); // Try pulling up MutableCalc only when: // 1. it's inner join. // 2. it's outer join but no filtering condition from MutableCalc. final JoinRelType joinRelType = sameJoinType(query.joinType, target.joinType); if (joinRelType == null) { return null; } if (joinRelType != JoinRelType.INNER && !(joinRelType.isOuterJoin() && qInput1Cond.isAlwaysTrue())) { return null; } // Try pulling up MutableCalc only when Join condition references mapping. final List<RexNode> identityProjects = (List<RexNode>) rexBuilder.identityProjects(qInput0.rowType); if (!referenceByMapping(query.condition, identityProjects, qInput1Projs)) { return null; } final RexNode newQueryJoinCond = new RexShuttle() { @Override public RexNode visitInputRef(RexInputRef inputRef) { final int idx = inputRef.getIndex(); if (idx < fieldCnt(qInput0)) { return inputRef; } else { final int newIdx = ((RexInputRef) qInput1Projs.get(idx - fieldCnt(qInput0))) .getIndex() + fieldCnt(qInput0); return new RexInputRef(newIdx, inputRef.getType()); } } }.apply(query.condition); final RexNode splitted = splitFilter(call.getSimplify(), newQueryJoinCond, target.condition); // MutableJoin matches only when the conditions are analyzed to be same. if (splitted != null && splitted.isAlwaysTrue()) { final RexNode compenCond = RexUtil.shift(qInput1Cond, qInput0.rowType.getFieldCount()); final List<RexNode> compenProjs = new ArrayList<>(); for (int i = 0; i < query.rowType.getFieldCount(); i++) { if (i < fieldCnt(qInput0)) { compenProjs.add( new RexInputRef(i, query.rowType.getFieldList().get(i).getType())); } else { final RexNode shifted = RexUtil.shift(qInput1Projs.get(i - fieldCnt(qInput0)), qInput0.rowType.getFieldCount()); compenProjs.add(shifted); } } final RexProgram compensatingRexProgram = RexProgram.create( target.rowType, compenProjs, compenCond, query.rowType, rexBuilder); final MutableCalc compenCalc = MutableCalc.of(target, compensatingRexProgram); return tryMergeParentCalcAndGenResult(call, compenCalc); } return null; }