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;
}
Aggregations