Search in sources :

Example 1 with SelectAllFilter

use of io.trino.operator.project.TestPageProcessor.SelectAllFilter in project trino by trinodb.

the class TestScanFilterAndProjectOperator method testPageSourceLazyLoad.

@Test
public void testPageSourceLazyLoad() {
    Block inputBlock = BlockAssertions.createLongSequenceBlock(0, 100);
    // If column 1 is loaded, test will fail
    Page input = new Page(100, inputBlock, new LazyBlock(100, () -> {
        throw new AssertionError("Lazy block should not be loaded");
    }));
    DriverContext driverContext = newDriverContext();
    List<RowExpression> projections = ImmutableList.of(field(0, VARCHAR));
    Supplier<CursorProcessor> cursorProcessor = functionAssertions.getExpressionCompiler().compileCursorProcessor(Optional.empty(), projections, "key");
    PageProcessor pageProcessor = new PageProcessor(Optional.of(new SelectAllFilter()), ImmutableList.of(new LazyPagePageProjection()));
    ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory factory = new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory(0, new PlanNodeId("test"), new PlanNodeId("0"), (session, split, table, columns, dynamicFilter) -> new SinglePagePageSource(input), cursorProcessor, () -> pageProcessor, TEST_TABLE_HANDLE, ImmutableList.of(), DynamicFilter.EMPTY, ImmutableList.of(BIGINT), DataSize.ofBytes(0), 0);
    SourceOperator operator = factory.createOperator(driverContext);
    operator.addSplit(new Split(new CatalogName("test"), TestingSplit.createLocalSplit(), Lifespan.taskWide()));
    operator.noMoreSplits();
    MaterializedResult expected = toMaterializedResult(driverContext.getSession(), ImmutableList.of(BIGINT), ImmutableList.of(new Page(inputBlock)));
    MaterializedResult actual = toMaterializedResult(driverContext.getSession(), ImmutableList.of(BIGINT), toPages(operator));
    assertEquals(actual.getRowCount(), expected.getRowCount());
    assertEquals(actual, expected);
}
Also used : CursorProcessor(io.trino.operator.project.CursorProcessor) RowExpression(io.trino.sql.relational.RowExpression) Page(io.trino.spi.Page) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) LazyBlock(io.trino.spi.block.LazyBlock) PageProcessor(io.trino.operator.project.PageProcessor) LazyPagePageProjection(io.trino.operator.project.TestPageProcessor.LazyPagePageProjection) LazyBlock(io.trino.spi.block.LazyBlock) Block(io.trino.spi.block.Block) SelectAllFilter(io.trino.operator.project.TestPageProcessor.SelectAllFilter) CatalogName(io.trino.connector.CatalogName) Split(io.trino.metadata.Split) TestingSplit(io.trino.testing.TestingSplit) MaterializedResult(io.trino.testing.MaterializedResult) OperatorAssertion.toMaterializedResult(io.trino.operator.OperatorAssertion.toMaterializedResult) Test(org.testng.annotations.Test)

Aggregations

CatalogName (io.trino.connector.CatalogName)1 Split (io.trino.metadata.Split)1 OperatorAssertion.toMaterializedResult (io.trino.operator.OperatorAssertion.toMaterializedResult)1 CursorProcessor (io.trino.operator.project.CursorProcessor)1 PageProcessor (io.trino.operator.project.PageProcessor)1 LazyPagePageProjection (io.trino.operator.project.TestPageProcessor.LazyPagePageProjection)1 SelectAllFilter (io.trino.operator.project.TestPageProcessor.SelectAllFilter)1 Page (io.trino.spi.Page)1 Block (io.trino.spi.block.Block)1 LazyBlock (io.trino.spi.block.LazyBlock)1 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)1 RowExpression (io.trino.sql.relational.RowExpression)1 MaterializedResult (io.trino.testing.MaterializedResult)1 TestingSplit (io.trino.testing.TestingSplit)1 Test (org.testng.annotations.Test)1