use of org.apache.drill.common.logical.data.NamedExpression in project drill by apache.
the class DrillProjectRel method implement.
@Override
public LogicalOperator implement(DrillImplementor implementor) {
LogicalOperator inputOp = implementor.visitChild(this, 0, getInput());
Project.Builder builder = Project.builder();
builder.setInput(inputOp);
for (NamedExpression e : this.getProjectExpressions(implementor.getContext())) {
builder.addExpr(e);
}
return builder.build();
}
use of org.apache.drill.common.logical.data.NamedExpression in project drill by apache.
the class DrillProjectRel method convert.
public static DrillProjectRel convert(Project project, ConversionContext context) throws InvalidRelException {
RelNode input = context.toRel(project.getInput());
List<RelDataTypeField> fields = Lists.newArrayList();
List<RexNode> exps = Lists.newArrayList();
for (NamedExpression expr : project.getSelections()) {
fields.add(new RelDataTypeFieldImpl(expr.getRef().getRootSegment().getPath(), fields.size(), context.getTypeFactory().createSqlType(SqlTypeName.ANY)));
exps.add(context.toRex(expr.getExpr()));
}
return new DrillProjectRel(context.getCluster(), context.getLogicalTraits(), input, exps, new RelRecordType(fields));
}
Aggregations