Search in sources :

Example 16 with NamedExpression

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();
}
Also used : Project(org.apache.drill.common.logical.data.Project) NamedExpression(org.apache.drill.common.logical.data.NamedExpression) LogicalOperator(org.apache.drill.common.logical.data.LogicalOperator)

Example 17 with NamedExpression

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));
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) RelNode(org.apache.calcite.rel.RelNode) NamedExpression(org.apache.drill.common.logical.data.NamedExpression) RelDataTypeFieldImpl(org.apache.calcite.rel.type.RelDataTypeFieldImpl) RelRecordType(org.apache.calcite.rel.type.RelRecordType) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

NamedExpression (org.apache.drill.common.logical.data.NamedExpression)17 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)11 FieldReference (org.apache.drill.common.expression.FieldReference)7 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)6 MaterializedField (org.apache.drill.exec.record.MaterializedField)6 ErrorCollector (org.apache.drill.common.expression.ErrorCollector)5 ErrorCollectorImpl (org.apache.drill.common.expression.ErrorCollectorImpl)5 ValueVector (org.apache.drill.exec.vector.ValueVector)5 ValueVectorWriteExpression (org.apache.drill.exec.expr.ValueVectorWriteExpression)4 TypedFieldId (org.apache.drill.exec.record.TypedFieldId)4 RexNode (org.apache.calcite.rex.RexNode)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 IntHashSet (com.carrotsearch.hppc.IntHashSet)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 AggregateCall (org.apache.calcite.rel.core.AggregateCall)2 FunctionCall (org.apache.drill.common.expression.FunctionCall)2 IfExpression (org.apache.drill.common.expression.IfExpression)2 Order (org.apache.drill.common.logical.data.Order)2 ClassTransformationException (org.apache.drill.exec.exception.ClassTransformationException)2