Beispiel #1
0
  /**
   * Constructs a MultiJoin.
   *
   * @param cluster cluster that join belongs to
   * @param inputs inputs into this multi-join
   * @param condition join filter applicable to this join node
   * @param rowType row type of the join result of this node
   * @param joinInputs
   * @param joinTypes the join type corresponding to each input; if an input is null-generating in a
   *     left or right outer join, the entry indicates the type of outer join; otherwise, the entry
   *     is set to INNER
   * @param filters filters associated with each join input
   * @param joinPredicateInfo join predicate information
   */
  public HiveMultiJoin(
      RelOptCluster cluster,
      List<RelNode> inputs,
      RexNode condition,
      RelDataType rowType,
      List<Pair<Integer, Integer>> joinInputs,
      List<JoinRelType> joinTypes,
      List<RexNode> filters,
      JoinPredicateInfo joinPredicateInfo) {
    super(cluster, TraitsUtil.getDefaultTraitSet(cluster));
    this.inputs = inputs;
    this.condition = condition;
    this.rowType = rowType;

    assert joinInputs.size() == joinTypes.size();
    this.joinInputs = ImmutableList.copyOf(joinInputs);
    this.joinTypes = ImmutableList.copyOf(joinTypes);
    this.filters = ImmutableList.copyOf(filters);
    this.outerJoin = containsOuter();
    if (joinPredicateInfo == null) {
      try {
        this.joinPredInfo = HiveCalciteUtil.JoinPredicateInfo.constructJoinPredicateInfo(this);
      } catch (CalciteSemanticException e) {
        throw new RuntimeException(e);
      }
    } else {
      this.joinPredInfo = joinPredicateInfo;
    }
  }
Beispiel #2
0
  public ImmutableBitSet getSortedInputs() throws CalciteSemanticException {
    ImmutableBitSet.Builder sortedInputsBuilder = ImmutableBitSet.builder();
    JoinPredicateInfo joinPredInfo =
        HiveCalciteUtil.JoinPredicateInfo.constructJoinPredicateInfo(this);
    List<ImmutableIntList> joinKeysInChildren = new ArrayList<ImmutableIntList>();
    joinKeysInChildren.add(
        ImmutableIntList.copyOf(joinPredInfo.getProjsFromLeftPartOfJoinKeysInChildSchema()));
    joinKeysInChildren.add(
        ImmutableIntList.copyOf(joinPredInfo.getProjsFromRightPartOfJoinKeysInChildSchema()));

    for (int i = 0; i < this.getInputs().size(); i++) {
      boolean correctOrderFound =
          RelCollations.contains(
              RelMetadataQuery.instance().collations(this.getInputs().get(i)),
              joinKeysInChildren.get(i));
      if (correctOrderFound) {
        sortedInputsBuilder.set(i);
      }
    }
    return sortedInputsBuilder.build();
  }
Beispiel #3
0
 protected HiveJoin(
     RelOptCluster cluster,
     RelTraitSet traits,
     RelNode left,
     RelNode right,
     RexNode condition,
     JoinRelType joinType,
     Set<String> variablesStopped,
     JoinAlgorithm joinAlgo,
     boolean leftSemiJoin)
     throws InvalidRelException, CalciteSemanticException {
   super(
       cluster,
       TraitsUtil.getDefaultTraitSet(cluster),
       left,
       right,
       condition,
       joinType,
       variablesStopped);
   final List<RelDataTypeField> systemFieldList = ImmutableList.of();
   List<List<RexNode>> joinKeyExprs = new ArrayList<List<RexNode>>();
   List<Integer> filterNulls = new ArrayList<Integer>();
   for (int i = 0; i < this.getInputs().size(); i++) {
     joinKeyExprs.add(new ArrayList<RexNode>());
   }
   this.joinFilter =
       HiveRelOptUtil.splitHiveJoinCondition(
           systemFieldList,
           this.getInputs(),
           this.getCondition(),
           joinKeyExprs,
           filterNulls,
           null);
   this.joinPredInfo = HiveCalciteUtil.JoinPredicateInfo.constructJoinPredicateInfo(this);
   this.joinAlgorithm = joinAlgo;
   this.leftSemiJoin = leftSemiJoin;
 }