Search in sources :

Example 61 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestWindowOperator method testFullyPreGroupedPartition.

@Test
public void testFullyPreGroupedPartition() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT, VARCHAR, BIGINT, VARCHAR).pageBreak().row(1L, "a", 100L, "A").pageBreak().row(2L, "a", 101L, "B").pageBreak().row(2L, "b", 102L, "D").row(2L, "b", 103L, "C").row(1L, "b", 104L, "E").pageBreak().row(1L, "b", 105L, "F").row(3L, "c", 106L, "G").build();
    WindowOperatorFactory operatorFactory = createFactoryUnbounded(ImmutableList.of(BIGINT, VARCHAR, BIGINT, VARCHAR), Ints.asList(0, 1, 2, 3), ROW_NUMBER, Ints.asList(1, 0), Ints.asList(0, 1), Ints.asList(3), ImmutableList.of(SortOrder.ASC_NULLS_LAST), 0);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, VARCHAR, BIGINT, VARCHAR, BIGINT).row(1L, "a", 100L, "A", 1L).row(2L, "a", 101L, "B", 1L).row(2L, "b", 103L, "C", 1L).row(2L, "b", 102L, "D", 2L).row(1L, "b", 104L, "E", 1L).row(1L, "b", 105L, "F", 2L).row(3L, "c", 106L, "G", 1L).build();
    assertOperatorEqualsIgnoreOrder(operatorFactory, driverContext, input, expected);
}
Also used : WindowOperatorFactory(com.facebook.presto.operator.WindowOperator.WindowOperatorFactory) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 62 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestWindowOperator method testRowNumber.

@Test
public void testRowNumber() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT, DOUBLE).row(2L, 0.3).row(4L, 0.2).row(6L, 0.1).pageBreak().row(-1L, -0.1).row(5L, 0.4).build();
    WindowOperatorFactory operatorFactory = createFactoryUnbounded(ImmutableList.of(BIGINT, DOUBLE), Ints.asList(1, 0), ROW_NUMBER, Ints.asList(), Ints.asList(0), ImmutableList.copyOf(new SortOrder[] { SortOrder.ASC_NULLS_LAST }));
    MaterializedResult expected = resultBuilder(driverContext.getSession(), DOUBLE, BIGINT, BIGINT).row(-0.1, -1L, 1L).row(0.3, 2L, 2L).row(0.2, 4L, 3L).row(0.4, 5L, 4L).row(0.1, 6L, 5L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : WindowOperatorFactory(com.facebook.presto.operator.WindowOperator.WindowOperatorFactory) SortOrder(com.facebook.presto.spi.block.SortOrder) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 63 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestWindowOperator method testLeadPartition.

@Test
public void testLeadPartition() throws Exception {
    List<Page> input = rowPagesBuilder(VARCHAR, VARCHAR, BIGINT, BIGINT, VARCHAR, BOOLEAN, VARCHAR).row("b", "A1", 1L, 1L, "D", true, "").row("a", "A2", 1L, 2L, "D", false, "").row("a", "B1", 2L, 2L, "D", true, "").pageBreak().row("b", "C1", 2L, 1L, "D", false, "").row("a", "C2", 3L, 2L, "D", true, "").row("c", "A3", 1L, 1L, "D", true, "").build();
    WindowOperatorFactory operatorFactory = createFactoryUnbounded(ImmutableList.of(VARCHAR, VARCHAR, BIGINT, BIGINT, VARCHAR, BOOLEAN, VARCHAR), Ints.asList(0, 1, 2, 5), LEAD, Ints.asList(0), Ints.asList(2), ImmutableList.copyOf(new SortOrder[] { SortOrder.ASC_NULLS_LAST }));
    MaterializedResult expected = resultBuilder(driverContext.getSession(), VARCHAR, VARCHAR, BIGINT, BOOLEAN, VARCHAR).row("a", "A2", 1L, false, "C2").row("a", "B1", 2L, true, "D").row("a", "C2", 3L, true, "D").row("b", "A1", 1L, true, "C1").row("b", "C1", 2L, false, "D").row("c", "A3", 1L, true, "D").build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : WindowOperatorFactory(com.facebook.presto.operator.WindowOperator.WindowOperatorFactory) SortOrder(com.facebook.presto.spi.block.SortOrder) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 64 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestWindowOperator method testFullyPreGroupedAndPartiallySortedPartition.

@Test
public void testFullyPreGroupedAndPartiallySortedPartition() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT, VARCHAR, BIGINT, VARCHAR).pageBreak().row(1L, "a", 100L, "A").pageBreak().row(2L, "a", 100L, "A").pageBreak().row(2L, "b", 102L, "A").row(2L, "b", 101L, "A").row(2L, "b", 100L, "B").row(1L, "b", 101L, "A").pageBreak().row(1L, "b", 100L, "A").row(3L, "c", 100L, "A").build();
    WindowOperatorFactory operatorFactory = createFactoryUnbounded(ImmutableList.of(BIGINT, VARCHAR, BIGINT, VARCHAR), Ints.asList(0, 1, 2, 3), ROW_NUMBER, Ints.asList(1, 0), Ints.asList(0, 1), Ints.asList(3, 2), ImmutableList.of(SortOrder.ASC_NULLS_LAST, SortOrder.ASC_NULLS_LAST), 1);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, VARCHAR, BIGINT, VARCHAR, BIGINT).row(1L, "a", 100L, "A", 1L).row(2L, "a", 100L, "A", 1L).row(2L, "b", 101L, "A", 1L).row(2L, "b", 102L, "A", 2L).row(2L, "b", 100L, "B", 3L).row(1L, "b", 100L, "A", 1L).row(1L, "b", 101L, "A", 2L).row(3L, "c", 100L, "A", 1L).build();
    assertOperatorEqualsIgnoreOrder(operatorFactory, driverContext, input, expected);
}
Also used : WindowOperatorFactory(com.facebook.presto.operator.WindowOperator.WindowOperatorFactory) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 65 with MaterializedResult

use of com.facebook.presto.testing.MaterializedResult in project presto by prestodb.

the class TestWindowOperator method testPartiallyPreGroupedPartitionWithEmptyInput.

@Test
public void testPartiallyPreGroupedPartitionWithEmptyInput() throws Exception {
    List<Page> input = rowPagesBuilder(BIGINT, VARCHAR, BIGINT, VARCHAR).pageBreak().pageBreak().build();
    WindowOperatorFactory operatorFactory = createFactoryUnbounded(ImmutableList.of(BIGINT, VARCHAR, BIGINT, VARCHAR), Ints.asList(0, 1, 2, 3), ROW_NUMBER, Ints.asList(0, 1), Ints.asList(1), Ints.asList(3), ImmutableList.of(SortOrder.ASC_NULLS_LAST), 0);
    MaterializedResult expected = resultBuilder(driverContext.getSession(), BIGINT, VARCHAR, BIGINT, VARCHAR, BIGINT).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : WindowOperatorFactory(com.facebook.presto.operator.WindowOperator.WindowOperatorFactory) Page(com.facebook.presto.spi.Page) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

MaterializedResult (com.facebook.presto.testing.MaterializedResult)298 Test (org.testng.annotations.Test)255 Page (com.facebook.presto.spi.Page)75 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)54 MaterializedRow (com.facebook.presto.testing.MaterializedRow)52 Type (com.facebook.presto.spi.type.Type)43 RowPagesBuilder (com.facebook.presto.RowPagesBuilder)35 Session (com.facebook.presto.Session)23 TestingTaskContext (com.facebook.presto.testing.TestingTaskContext)21 AbstractTestIntegrationSmokeTest (com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)20 ImmutableList (com.google.common.collect.ImmutableList)20 ColumnHandle (com.facebook.presto.spi.ColumnHandle)19 ConnectorSession (com.facebook.presto.spi.ConnectorSession)18 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)18 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)17 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)17 ImmutableMap (com.google.common.collect.ImmutableMap)17 List (java.util.List)17 BIGINT (com.facebook.presto.spi.type.BigintType.BIGINT)16 Path (org.apache.hadoop.fs.Path)14