Search in sources :

Example 31 with ErrorCollector

use of org.apache.drill.common.expression.ErrorCollector in project drill by apache.

the class ExpressionInterpreterTest method evalExprWithInterpreter.

private ValueVector evalExprWithInterpreter(String expression, RecordBatch batch, Drillbit bit) throws Exception {
    final LogicalExpression expr = parseExpr(expression);
    final ErrorCollector error = new ErrorCollectorImpl();
    final LogicalExpression materializedExpr = ExpressionTreeMaterializer.materialize(expr, batch, error, bit.getContext().getFunctionImplementationRegistry());
    if (error.getErrorCount() != 0) {
        logger.error("Failure while materializing expression [{}].  Errors: {}", expression, error);
        assertEquals(0, error.getErrorCount());
    }
    final MaterializedField outputField = MaterializedField.create("outCol", materializedExpr.getMajorType());
    final ValueVector vector = TypeHelper.getNewVector(outputField, bit.getContext().getAllocator());
    vector.allocateNewSafe();
    InterpreterEvaluator.evaluate(batch, vector, materializedExpr);
    return vector;
}
Also used : ErrorCollectorImpl(org.apache.drill.common.expression.ErrorCollectorImpl) ValueVector(org.apache.drill.exec.vector.ValueVector) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) ErrorCollector(org.apache.drill.common.expression.ErrorCollector) MaterializedField(org.apache.drill.exec.record.MaterializedField)

Aggregations

ErrorCollector (org.apache.drill.common.expression.ErrorCollector)31 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)31 ErrorCollectorImpl (org.apache.drill.common.expression.ErrorCollectorImpl)30 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)18 HoldingContainer (org.apache.drill.exec.expr.ClassGenerator.HoldingContainer)10 TypedFieldId (org.apache.drill.exec.record.TypedFieldId)10 Ordering (org.apache.drill.common.logical.data.Order.Ordering)9 MaterializedField (org.apache.drill.exec.record.MaterializedField)9 ValueVector (org.apache.drill.exec.vector.ValueVector)9 JConditional (com.sun.codemodel.JConditional)8 IOException (java.io.IOException)8 ClassTransformationException (org.apache.drill.exec.exception.ClassTransformationException)7 SchemaPath (org.apache.drill.common.expression.SchemaPath)6 ValueVectorWriteExpression (org.apache.drill.exec.expr.ValueVectorWriteExpression)6 TransferPair (org.apache.drill.exec.record.TransferPair)6 FieldReference (org.apache.drill.common.expression.FieldReference)5 NamedExpression (org.apache.drill.common.logical.data.NamedExpression)5 ExecTest (org.apache.drill.exec.ExecTest)4 NonStrictExpectations (mockit.NonStrictExpectations)3 IfExpression (org.apache.drill.common.expression.IfExpression)3