use of org.apache.drill.common.logical.data.LogicalSemiJoin in project drill by apache.
the class DrillSemiJoinRel method implement.
@Override
public LogicalOperator implement(DrillImplementor implementor) {
List<String> fields = new ArrayList<>();
fields.addAll(getInput(0).getRowType().getFieldNames());
fields.addAll(getInput(1).getRowType().getFieldNames());
Preconditions.checkArgument(DrillJoinRel.isUnique(fields));
final int leftCount = left.getRowType().getFieldCount();
final List<String> leftFields = fields.subList(0, leftCount);
final List<String> rightFields = fields.subList(leftCount, leftCount + right.getRowType().getFieldCount());
final LogicalOperator leftOp = DrillJoinRel.implementInput(implementor, 0, 0, left, this, fields);
final LogicalOperator rightOp = DrillJoinRel.implementInput(implementor, 1, leftCount, right, this, fields);
Join.Builder builder = Join.builder();
builder.type(joinType);
builder.left(leftOp);
builder.right(rightOp);
List<JoinCondition> conditions = Lists.newArrayList();
for (Pair<Integer, Integer> pair : Pair.zip(leftKeys, rightKeys)) {
conditions.add(new JoinCondition(DrillJoinRel.EQUALITY_CONDITION, new FieldReference(leftFields.get(pair.left)), new FieldReference(rightFields.get(pair.right))));
}
return new LogicalSemiJoin(leftOp, rightOp, conditions, joinType);
}
Aggregations