use of org.apache.calcite.rel.RelDistribution in project hive by apache.
the class HiveAlgorithmsUtil method getJoinDistribution.
public static RelDistribution getJoinDistribution(JoinPredicateInfo joinPredInfo, MapJoinStreamingRelation streamingRelation) {
// Compute distribution
ImmutableList.Builder<Integer> leftKeysListBuilder = new ImmutableList.Builder<Integer>();
ImmutableList.Builder<Integer> rightKeysListBuilder = new ImmutableList.Builder<Integer>();
for (int i = 0; i < joinPredInfo.getEquiJoinPredicateElements().size(); i++) {
JoinLeafPredicateInfo joinLeafPredInfo = joinPredInfo.getEquiJoinPredicateElements().get(i);
for (int leftPos : joinLeafPredInfo.getProjsFromLeftPartOfJoinKeysInJoinSchema()) {
leftKeysListBuilder.add(leftPos);
}
for (int rightPos : joinLeafPredInfo.getProjsFromRightPartOfJoinKeysInJoinSchema()) {
rightKeysListBuilder.add(rightPos);
}
}
RelDistribution distribution = null;
// Keep buckets from the streaming relation
if (streamingRelation == MapJoinStreamingRelation.LEFT_RELATION) {
distribution = new HiveRelDistribution(RelDistribution.Type.HASH_DISTRIBUTED, leftKeysListBuilder.build());
} else if (streamingRelation == MapJoinStreamingRelation.RIGHT_RELATION) {
distribution = new HiveRelDistribution(RelDistribution.Type.HASH_DISTRIBUTED, rightKeysListBuilder.build());
}
return distribution;
}
use of org.apache.calcite.rel.RelDistribution in project hive by apache.
the class HiveOpConverter method visit.
OpAttr visit(HiveSortExchange exchangeRel) throws SemanticException {
OpAttr inputOpAf = dispatch(exchangeRel.getInput());
String tabAlias = inputOpAf.tabAlias;
if (tabAlias == null || tabAlias.length() == 0) {
tabAlias = getHiveDerivedTableAlias();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Translating operator rel#" + exchangeRel.getId() + ":" + exchangeRel.getRelTypeName() + " with row type: [" + exchangeRel.getRowType() + "]");
}
RelDistribution distribution = exchangeRel.getDistribution();
if (distribution.getType() != Type.HASH_DISTRIBUTED) {
throw new SemanticException("Only hash distribution supported for LogicalExchange");
}
ExprNodeDesc[] expressions = new ExprNodeDesc[exchangeRel.getJoinKeys().size()];
for (int index = 0; index < exchangeRel.getJoinKeys().size(); index++) {
expressions[index] = convertToExprNode(exchangeRel.getJoinKeys().get(index), exchangeRel.getInput(), inputOpAf.tabAlias, inputOpAf);
}
exchangeRel.setJoinExpressions(expressions);
ReduceSinkOperator rsOp = genReduceSink(inputOpAf.inputs.get(0), tabAlias, expressions, -1, -1, Operation.NOT_ACID, hiveConf);
return new OpAttr(tabAlias, inputOpAf.vcolsInCalcite, rsOp);
}
Aggregations