Search in sources :

Example 6 with RowPagesBuilder

use of io.trino.RowPagesBuilder in project trino by trinodb.

the class TestSpatialJoinOperator method testSpatialLeftJoin.

@Test
public void testSpatialLeftJoin() {
    TaskContext taskContext = createTaskContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POLYGON_A, "A").row(null, "null").pageBreak().row(POLYGON_B, "B");
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POINT_X, "x").row(null, "null").row(POINT_Y, "y").pageBreak().row(POINT_Z, "z").pageBreak().row(POINT_W, "w");
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).row("x", "A").row("null", null).row("y", "A").row("y", "B").row("z", "B").row("w", null).build();
    assertSpatialJoin(taskContext, LEFT, buildPages, probePages, expected);
}
Also used : TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) RowPagesBuilder(io.trino.RowPagesBuilder) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 7 with RowPagesBuilder

use of io.trino.RowPagesBuilder in project trino by trinodb.

the class TestSpatialJoinOperator method testEmptyProbe.

@Test
public void testEmptyProbe() {
    TaskContext taskContext = createTaskContext();
    RowPagesBuilder buildPages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR)).row(POLYGON_A, "A").row(null, "null").pageBreak().row(POLYGON_B, "B");
    RowPagesBuilder probePages = rowPagesBuilder(ImmutableList.of(GEOMETRY, VARCHAR));
    MaterializedResult expected = resultBuilder(taskContext.getSession(), ImmutableList.of(VARCHAR, VARCHAR)).build();
    assertSpatialJoin(taskContext, INNER, buildPages, probePages, expected);
}
Also used : TestingTaskContext(io.trino.testing.TestingTaskContext) TaskContext(io.trino.operator.TaskContext) RowPagesBuilder(io.trino.RowPagesBuilder) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 8 with RowPagesBuilder

use of io.trino.RowPagesBuilder in project trino by trinodb.

the class TestDistinctLimitOperator method testDistinctLimitValuesLessThanLimit.

@Test(dataProvider = "hashEnabledValues")
public void testDistinctLimitValuesLessThanLimit(boolean hashEnabled) {
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), BIGINT);
    List<Page> input = rowPagesBuilder.addSequencePage(3, 1).addSequencePage(3, 2).build();
    OperatorFactory operatorFactory = new DistinctLimitOperator.DistinctLimitOperatorFactory(0, new PlanNodeId("test"), rowPagesBuilder.getTypes(), Ints.asList(0), 5, rowPagesBuilder.getHashChannel(), joinCompiler, blockTypeOperators);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT).row(1L).row(2L).row(3L).row(4L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected, hashEnabled, ImmutableList.of(1));
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) RowPagesBuilder(io.trino.RowPagesBuilder) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 9 with RowPagesBuilder

use of io.trino.RowPagesBuilder in project trino by trinodb.

the class TestStreamingAggregationOperator method testEmptyInput.

@Test
public void testEmptyInput() {
    RowPagesBuilder rowPagesBuilder = RowPagesBuilder.rowPagesBuilder(BOOLEAN, VARCHAR, BIGINT);
    List<Page> input = rowPagesBuilder.build();
    MaterializedResult expected = resultBuilder(driverContext.getSession(), VARCHAR, BIGINT, BIGINT).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : RowPagesBuilder(io.trino.RowPagesBuilder) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 10 with RowPagesBuilder

use of io.trino.RowPagesBuilder in project trino by trinodb.

the class TestStreamingAggregationOperator method testUniqueGroupingValues.

@Test
public void testUniqueGroupingValues() {
    RowPagesBuilder rowPagesBuilder = RowPagesBuilder.rowPagesBuilder(BOOLEAN, VARCHAR, BIGINT);
    List<Page> input = rowPagesBuilder.addSequencePage(10, 0, 0, 0).addSequencePage(10, 0, 10, 10).build();
    MaterializedResult.Builder builder = resultBuilder(driverContext.getSession(), VARCHAR, BIGINT, BIGINT);
    for (int i = 0; i < 20; i++) {
        builder.row(format("%s", i), 1L, Long.valueOf(i));
    }
    assertOperatorEquals(operatorFactory, driverContext, input, builder.build());
}
Also used : RowPagesBuilder(io.trino.RowPagesBuilder) Page(io.trino.spi.Page) MaterializedResult(io.trino.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

RowPagesBuilder (io.trino.RowPagesBuilder)84 Test (org.testng.annotations.Test)81 Page (io.trino.spi.Page)71 MaterializedResult (io.trino.testing.MaterializedResult)64 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)47 TaskContext (io.trino.operator.TaskContext)46 TestingTaskContext (io.trino.testing.TestingTaskContext)46 Type (io.trino.spi.type.Type)38 OperatorFactory (io.trino.operator.OperatorFactory)29 BuildSideSetup (io.trino.operator.join.JoinTestUtils.BuildSideSetup)26 WorkProcessorOperatorFactory (io.trino.operator.WorkProcessorOperatorFactory)25 ValuesOperatorFactory (io.trino.operator.ValuesOperator.ValuesOperatorFactory)24 PageBufferOperatorFactory (io.trino.operator.index.PageBufferOperator.PageBufferOperatorFactory)24 JoinTestUtils.innerJoinOperatorFactory (io.trino.operator.join.JoinTestUtils.innerJoinOperatorFactory)24 DriverContext (io.trino.operator.DriverContext)14 Operator (io.trino.operator.Operator)12 HashAggregationOperatorFactory (io.trino.operator.HashAggregationOperator.HashAggregationOperatorFactory)11 WorkProcessorOperator (io.trino.operator.WorkProcessorOperator)11 NestedLoopJoinOperatorFactory (io.trino.operator.join.NestedLoopJoinOperator.NestedLoopJoinOperatorFactory)10 StageId (io.trino.execution.StageId)8