Search in sources :

Example 81 with MaterializedResult

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

the class AbstractTestQueries method testValueWindowFunctions.

@Test
public void testValueWindowFunctions() {
    MaterializedResult actual = computeActual("SELECT * FROM (\n" + "  SELECT orderkey, orderstatus\n" + "    , first_value(orderkey + 1000) OVER (PARTITION BY orderstatus ORDER BY orderkey) fvalue\n" + "    , nth_value(orderkey + 1000, 2) OVER (PARTITION BY orderstatus ORDER BY orderkey\n" + "        ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) nvalue\n" + "    FROM (SELECT * FROM orders ORDER BY orderkey LIMIT 10) x\n" + "  ) x\n" + "ORDER BY orderkey LIMIT 5");
    MaterializedResult expected = resultBuilder(getSession(), BIGINT, VARCHAR, BIGINT, BIGINT).row(1L, "O", 1001L, 1002L).row(2L, "O", 1001L, 1002L).row(3L, "F", 1003L, 1005L).row(4L, "O", 1001L, 1002L).row(5L, "F", 1003L, 1005L).build();
    assertEquals(actual, expected);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 82 with MaterializedResult

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

the class AbstractTestQueries method testApproxSetGroupByWithNulls.

@Test
public void testApproxSetGroupByWithNulls() {
    MaterializedResult actual = computeActual("" + "SELECT orderstatus, cardinality(approx_set(IF(custkey % 2 <> 0, custkey))) " + "FROM orders " + "GROUP BY orderstatus");
    MaterializedResult expected = resultBuilder(getSession(), actual.getTypes()).row("O", 499L).row("F", 496L).row("P", 153L).build();
    assertEqualsIgnoreOrder(actual.getMaterializedRows(), expected.getMaterializedRows());
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 83 with MaterializedResult

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

the class AbstractTestQueries method testNonDeterministicProjection.

@Test
public void testNonDeterministicProjection() {
    MaterializedResult materializedResult = computeActual("select r, r + 1 from (select rand(100) r from orders) limit 10");
    assertEquals(materializedResult.getRowCount(), 10);
    for (MaterializedRow materializedRow : materializedResult) {
        assertEquals(materializedRow.getFieldCount(), 2);
        assertEquals(((Number) materializedRow.getField(0)).intValue() + 1, materializedRow.getField(1));
    }
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) MaterializedRow(com.facebook.presto.testing.MaterializedRow) Test(org.testng.annotations.Test)

Example 84 with MaterializedResult

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

the class AbstractTestQueries method assertExplainDdl.

private void assertExplainDdl(String query, String expected) {
    MaterializedResult result = computeActual("EXPLAIN " + query);
    assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), expected);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult)

Example 85 with MaterializedResult

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

the class AbstractTestQueries method testP4ApproxSetGroupByWithNulls.

@Test
public void testP4ApproxSetGroupByWithNulls() {
    MaterializedResult actual = computeActual("" + "SELECT orderstatus, cardinality(cast(approx_set(IF(custkey % 2 <> 0, custkey)) AS P4HYPERLOGLOG)) " + "FROM orders " + "GROUP BY orderstatus");
    MaterializedResult expected = resultBuilder(getSession(), actual.getTypes()).row("O", 495L).row("F", 491L).row("P", 153L).build();
    assertEqualsIgnoreOrder(actual.getMaterializedRows(), expected.getMaterializedRows());
}
Also used : 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