Search in sources :

Example 6 with JoinPredicateInfo

use of org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil.JoinPredicateInfo in project hive by apache.

the class HiveJoinToMultiJoinRule method isCombinableJoin.

/*
   * Returns true if the join conditions execute over the same keys
   */
private static boolean isCombinableJoin(HiveJoin join, HiveMultiJoin leftChildJoin) throws CalciteSemanticException {
    final JoinPredicateInfo joinPredInfo = HiveCalciteUtil.JoinPredicateInfo.constructJoinPredicateInfo(join, join.getCondition());
    final JoinPredicateInfo leftChildJoinPredInfo = HiveCalciteUtil.JoinPredicateInfo.constructJoinPredicateInfo(leftChildJoin, leftChildJoin.getCondition());
    return isCombinablePredicate(joinPredInfo, leftChildJoinPredInfo, leftChildJoin.getInputs().size());
}
Also used : JoinPredicateInfo(org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil.JoinPredicateInfo)

Example 7 with JoinPredicateInfo

use of org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil.JoinPredicateInfo in project hive by apache.

the class HiveJoin method getSortedInputs.

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()));
    final RelMetadataQuery mq = this.left.getCluster().getMetadataQuery();
    for (int i = 0; i < this.getInputs().size(); i++) {
        boolean correctOrderFound = RelCollations.contains(mq.collations(this.getInputs().get(i)), joinKeysInChildren.get(i));
        if (correctOrderFound) {
            sortedInputsBuilder.set(i);
        }
    }
    return sortedInputsBuilder.build();
}
Also used : RelMetadataQuery(org.apache.calcite.rel.metadata.RelMetadataQuery) ImmutableBitSet(org.apache.calcite.util.ImmutableBitSet) JoinPredicateInfo(org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil.JoinPredicateInfo) ArrayList(java.util.ArrayList) ImmutableIntList(org.apache.calcite.util.ImmutableIntList)

Aggregations

JoinPredicateInfo (org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil.JoinPredicateInfo)7 ArrayList (java.util.ArrayList)4 RexNode (org.apache.calcite.rex.RexNode)4 CalciteSemanticException (org.apache.hadoop.hive.ql.optimizer.calcite.CalciteSemanticException)4 HiveJoin (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveJoin)4 RelNode (org.apache.calcite.rel.RelNode)3 JoinLeafPredicateInfo (org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil.JoinLeafPredicateInfo)3 ImmutableList (com.google.common.collect.ImmutableList)2 Join (org.apache.calcite.rel.core.Join)2 RexBuilder (org.apache.calcite.rex.RexBuilder)2 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)2 HiveMultiJoin (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveMultiJoin)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 List (java.util.List)1 RelOptCluster (org.apache.calcite.plan.RelOptCluster)1 RelFieldCollation (org.apache.calcite.rel.RelFieldCollation)1 Exchange (org.apache.calcite.rel.core.Exchange)1 JoinRelType (org.apache.calcite.rel.core.JoinRelType)1 SemiJoin (org.apache.calcite.rel.core.SemiJoin)1 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)1