Search in sources :

Example 1 with CursorProcessor

use of com.facebook.presto.operator.CursorProcessor in project presto by prestodb.

the class FunctionAssertions method compileScanFilterProject.

private SourceOperatorFactory compileScanFilterProject(Expression filter, Expression projection, ExpressionCompiler compiler) {
    filter = new SymbolToInputRewriter(INPUT_MAPPING).rewrite(filter);
    projection = new SymbolToInputRewriter(INPUT_MAPPING).rewrite(projection);
    IdentityLinkedHashMap<Expression, Type> expressionTypes = getExpressionTypesFromInput(TEST_SESSION, metadata, SQL_PARSER, INPUT_TYPES, ImmutableList.of(filter, projection), emptyList());
    try {
        Supplier<CursorProcessor> cursorProcessor = compiler.compileCursorProcessor(toRowExpression(filter, expressionTypes), ImmutableList.of(toRowExpression(projection, expressionTypes)), SOURCE_ID);
        Supplier<PageProcessor> pageProcessor = compiler.compilePageProcessor(toRowExpression(filter, expressionTypes), ImmutableList.of(toRowExpression(projection, expressionTypes)));
        return new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory(0, new PlanNodeId("test"), SOURCE_ID, PAGE_SOURCE_PROVIDER, cursorProcessor, pageProcessor, ImmutableList.of(), ImmutableList.of(expressionTypes.get(projection)));
    } catch (Throwable e) {
        if (e instanceof UncheckedExecutionException) {
            e = e.getCause();
        }
        throw new RuntimeException("Error compiling " + projection + ": " + e.getMessage(), e);
    }
}
Also used : CursorProcessor(com.facebook.presto.operator.CursorProcessor) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) Type(com.facebook.presto.spi.type.Type) PageProcessor(com.facebook.presto.operator.PageProcessor) GenericPageProcessor(com.facebook.presto.operator.GenericPageProcessor) RowExpression(com.facebook.presto.sql.relational.RowExpression) CanonicalizeExpressions.canonicalizeExpression(com.facebook.presto.sql.planner.optimizations.CanonicalizeExpressions.canonicalizeExpression) DereferenceExpression(com.facebook.presto.sql.tree.DereferenceExpression) Expression(com.facebook.presto.sql.tree.Expression) SymbolToInputRewriter(com.facebook.presto.sql.planner.SymbolToInputRewriter)

Aggregations

CursorProcessor (com.facebook.presto.operator.CursorProcessor)1 GenericPageProcessor (com.facebook.presto.operator.GenericPageProcessor)1 PageProcessor (com.facebook.presto.operator.PageProcessor)1 Type (com.facebook.presto.spi.type.Type)1 SymbolToInputRewriter (com.facebook.presto.sql.planner.SymbolToInputRewriter)1 CanonicalizeExpressions.canonicalizeExpression (com.facebook.presto.sql.planner.optimizations.CanonicalizeExpressions.canonicalizeExpression)1 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)1 RowExpression (com.facebook.presto.sql.relational.RowExpression)1 DereferenceExpression (com.facebook.presto.sql.tree.DereferenceExpression)1 Expression (com.facebook.presto.sql.tree.Expression)1 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)1