Search in sources :

Example 86 with MaterializedResult

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

the class AbstractTestQueries method testDescribeInput.

@Test
public void testDescribeInput() {
    Session session = Session.builder(getSession()).addPreparedStatement("my_query", "select ? from nation where nationkey = ? and name < ?").build();
    MaterializedResult actual = computeActual(session, "DESCRIBE INPUT my_query");
    MaterializedResult expected = resultBuilder(session, BIGINT, VARCHAR).row(0, "unknown").row(1, "bigint").row(2, "varchar").build();
    assertEqualsIgnoreOrder(actual, expected);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Example 87 with MaterializedResult

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

the class AbstractTestQueries method testTopNUnpartitionedWindowWithEqualityFilter.

@Test
public void testTopNUnpartitionedWindowWithEqualityFilter() {
    MaterializedResult actual = computeActual("" + "SELECT * FROM (\n" + "   SELECT row_number() OVER (ORDER BY orderkey) rn, orderkey, orderstatus\n" + "   FROM orders\n" + ") WHERE rn = 2");
    MaterializedResult expected = resultBuilder(getSession(), BIGINT, BIGINT, VARCHAR).row(2L, 2L, "O").build();
    assertEqualsIgnoreOrder(actual.getMaterializedRows(), expected.getMaterializedRows());
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 88 with MaterializedResult

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

the class AbstractTestQueries method testDescribeOutput.

@Test
public void testDescribeOutput() {
    Session session = Session.builder(getSession()).addPreparedStatement("my_query", "SELECT * FROM nation").build();
    MaterializedResult actual = computeActual(session, "DESCRIBE OUTPUT my_query");
    MaterializedResult expected = resultBuilder(session, VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, BIGINT, BOOLEAN).row("nationkey", session.getCatalog().get(), session.getSchema().get(), "nation", "bigint", 8, false).row("name", session.getCatalog().get(), session.getSchema().get(), "nation", "varchar(25)", 0, false).row("regionkey", session.getCatalog().get(), session.getSchema().get(), "nation", "bigint", 8, false).row("comment", session.getCatalog().get(), session.getSchema().get(), "nation", "varchar(152)", 0, false).build();
    assertEqualsIgnoreOrder(actual, expected);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Example 89 with MaterializedResult

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

the class AbstractTestQueries method testExplainOfExplainAnalyze.

@Test
public void testExplainOfExplainAnalyze() {
    String query = "EXPLAIN ANALYZE SELECT * FROM orders";
    MaterializedResult result = computeActual("EXPLAIN " + query);
    assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), getExplainPlan(query, LOGICAL));
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 90 with MaterializedResult

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

the class AbstractTestQueries method testApproxSetWithNulls.

@Test
public void testApproxSetWithNulls() {
    MaterializedResult actual = computeActual("SELECT cardinality(approx_set(IF(orderstatus = 'O', custkey))) FROM orders");
    MaterializedResult expected = resultBuilder(getSession(), actual.getTypes()).row(1001L).build();
    assertEquals(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