use of org.apache.drill.exec.planner.physical.UnnestPrel in project drill by apache.
the class AdjustOperatorsSchemaVisitor method visitUnnest.
@Override
public Prel visitUnnest(UnnestPrel prel, Void value) throws RuntimeException {
Preconditions.checkArgument(registeredPrel != null && registeredPrel instanceof LateralJoinPrel);
Preconditions.checkArgument(prel.getRowType().getFieldCount() == 1);
RexBuilder builder = prel.getCluster().getRexBuilder();
LateralJoinPrel lateralJoinPrel = (LateralJoinPrel) getRegisteredPrel();
int correlationIndex = lateralJoinPrel.getRequiredColumns().nextSetBit(0);
String correlationColumnName = lateralJoinPrel.getLeft().getRowType().getFieldNames().get(correlationIndex);
RexNode corrRef = builder.makeCorrel(lateralJoinPrel.getLeft().getRowType(), lateralJoinPrel.getCorrelationId());
RexNode fieldAccess = builder.makeFieldAccess(corrRef, correlationColumnName, false);
List<String> fieldNames = new ArrayList<>();
List<RelDataType> fieldTypes = new ArrayList<>();
for (RelDataTypeField field : prel.getRowType().getFieldList()) {
fieldNames.add(correlationColumnName);
fieldTypes.add(field.getType());
}
UnnestPrel unnestPrel = new UnnestPrel(prel.getCluster(), prel.getTraitSet(), prel.getCluster().getTypeFactory().createStructType(fieldTypes, fieldNames), fieldAccess);
return unnestPrel;
}
Aggregations