Search in sources :

Example 6 with ExpressionCompiler

use of io.trino.sql.gen.ExpressionCompiler in project trino by trinodb.

the class TestFilterAndProjectOperator method test.

@Test
public void test() {
    List<Page> input = rowPagesBuilder(VARCHAR, BIGINT).addSequencePage(100, 0, 0).build();
    TestingFunctionResolution functionResolution = new TestingFunctionResolution();
    RowExpression filter = call(functionResolution.resolveOperator(LESS_THAN_OR_EQUAL, ImmutableList.of(BIGINT, BIGINT)), field(1, BIGINT), constant(9L, BIGINT));
    RowExpression field0 = field(0, VARCHAR);
    RowExpression add5 = call(functionResolution.resolveOperator(ADD, ImmutableList.of(BIGINT, BIGINT)), field(1, BIGINT), constant(5L, BIGINT));
    ExpressionCompiler compiler = functionResolution.getExpressionCompiler();
    Supplier<PageProcessor> processor = compiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field0, add5));
    OperatorFactory operatorFactory = FilterAndProjectOperator.createOperatorFactory(0, new PlanNodeId("test"), processor, ImmutableList.of(VARCHAR, BIGINT), DataSize.ofBytes(0), 0);
    MaterializedResult expected = MaterializedResult.resultBuilder(driverContext.getSession(), VARCHAR, BIGINT).row("0", 5L).row("1", 6L).row("2", 7L).row("3", 8L).row("4", 9L).row("5", 10L).row("6", 11L).row("7", 12L).row("8", 13L).row("9", 14L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : TestingFunctionResolution(io.trino.metadata.TestingFunctionResolution) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) PageProcessor(io.trino.operator.project.PageProcessor) RowExpression(io.trino.sql.relational.RowExpression) Page(io.trino.spi.Page) ExpressionCompiler(io.trino.sql.gen.ExpressionCompiler) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 7 with ExpressionCompiler

use of io.trino.sql.gen.ExpressionCompiler in project trino by trinodb.

the class PredicateFilterBenchmark method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
    RowExpression filter = call(localQueryRunner.getMetadata().resolveOperator(session, LESS_THAN_OR_EQUAL, ImmutableList.of(DOUBLE, DOUBLE)), constant(50000.0, DOUBLE), field(0, DOUBLE));
    ExpressionCompiler expressionCompiler = new ExpressionCompiler(localQueryRunner.getFunctionManager(), new PageFunctionCompiler(localQueryRunner.getFunctionManager(), 0));
    Supplier<PageProcessor> pageProcessor = expressionCompiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field(0, DOUBLE)));
    OperatorFactory filterAndProjectOperator = FilterAndProjectOperator.createOperatorFactory(1, new PlanNodeId("test"), pageProcessor, ImmutableList.of(DOUBLE), DataSize.ofBytes(0), 0);
    return ImmutableList.of(tableScanOperator, filterAndProjectOperator);
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) PageFunctionCompiler(io.trino.sql.gen.PageFunctionCompiler) PageProcessor(io.trino.operator.project.PageProcessor) OperatorFactory(io.trino.operator.OperatorFactory) RowExpression(io.trino.sql.relational.RowExpression) ExpressionCompiler(io.trino.sql.gen.ExpressionCompiler)

Aggregations

ExpressionCompiler (io.trino.sql.gen.ExpressionCompiler)7 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)6 PageProcessor (io.trino.operator.project.PageProcessor)5 RowExpression (io.trino.sql.relational.RowExpression)5 Page (io.trino.spi.Page)4 PageFunctionCompiler (io.trino.sql.gen.PageFunctionCompiler)4 CatalogName (io.trino.connector.CatalogName)3 Split (io.trino.metadata.Split)3 Test (org.testng.annotations.Test)3 ImmutableList (com.google.common.collect.ImmutableList)2 TEST_SESSION (io.trino.SessionTestUtils.TEST_SESSION)2 FunctionManager (io.trino.metadata.FunctionManager)2 InternalFunctionBundle (io.trino.metadata.InternalFunctionBundle)2 TestingFunctionResolution (io.trino.metadata.TestingFunctionResolution)2 PageRecordSet (io.trino.operator.index.PageRecordSet)2 CursorProcessor (io.trino.operator.project.CursorProcessor)2 RecordPageSource (io.trino.spi.connector.RecordPageSource)2 MaterializedResult (io.trino.testing.MaterializedResult)2 TestingSplit (io.trino.testing.TestingSplit)2 ImmutableMap (com.google.common.collect.ImmutableMap)1