Search in sources :

Example 81 with Session

use of com.facebook.presto.Session in project presto by prestodb.

the class AbstractTestQueries method assertDescribeOutputEmpty.

private void assertDescribeOutputEmpty(@Language("SQL") String sql) {
    Session session = Session.builder(getSession()).addPreparedStatement("my_query", sql).build();
    MaterializedResult actual = computeActual(session, "DESCRIBE OUTPUT my_query");
    MaterializedResult expected = resultBuilder(session, VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, BIGINT, BOOLEAN).build();
    assertEqualsIgnoreOrder(actual, expected);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Session(com.facebook.presto.Session)

Example 82 with Session

use of com.facebook.presto.Session in project presto by prestodb.

the class AbstractTestQueries method testDescribeOutputOnAliasedColumnsAndExpressions.

@Test
public void testDescribeOutputOnAliasedColumnsAndExpressions() {
    Session session = Session.builder(getSession()).addPreparedStatement("my_query", "select count(*) as this_is_aliased, 1 + 2 from nation").build();
    MaterializedResult actual = computeActual(session, "DESCRIBE OUTPUT my_query");
    MaterializedResult expected = resultBuilder(session, VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, BIGINT, BOOLEAN).row("this_is_aliased", "", "", "", "bigint", 8, true).row("_col1", "", "", "", "integer", 4, false).build();
    assertEqualsIgnoreOrder(actual, expected);
}
Also used : MaterializedResult(com.facebook.presto.testing.MaterializedResult) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Example 83 with Session

use of com.facebook.presto.Session in project presto by prestodb.

the class AbstractTestQueries method testExecuteUsingWithSubqueryInJoin.

@Test
public void testExecuteUsingWithSubqueryInJoin() {
    String query = "SELECT * " + "FROM " + "    (VALUES ?,2,3) t(x) " + "  JOIN " + "    (VALUES 1,2,3) t2(y) " + "  ON " + "(x in (VALUES 1,2,?)) = (y in (VALUES 1,2,3)) AND (x in (VALUES 1,?)) = (y in (VALUES 1,2))";
    Session session = Session.builder(getSession()).addPreparedStatement("my_query", query).build();
    assertQuery(session, "EXECUTE my_query USING 1, 3, 2", "VALUES (1,1), (1,2), (2,2), (2,1), (3,3)");
}
Also used : Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Example 84 with Session

use of com.facebook.presto.Session in project presto by prestodb.

the class AbstractTestQueries method testExecuteUsing.

@Test
public void testExecuteUsing() {
    String query = "SELECT a + 1, count(?) FROM (VALUES 1, 2, 3, 2) t1(a) JOIN (VALUES 1, 2, 3, 4) t2(b) ON b < ? WHERE a < ? GROUP BY a + 1 HAVING count(1) > ?";
    Session session = Session.builder(getSession()).addPreparedStatement("my_query", query).build();
    assertQuery(session, "EXECUTE my_query USING 1, 5, 4, 0", "VALUES (2, 4), (3, 8), (4, 4)");
}
Also used : Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Example 85 with Session

use of com.facebook.presto.Session in project presto by prestodb.

the class AbstractTestQueries method testExecute.

@Test
public void testExecute() {
    Session session = Session.builder(getSession()).addPreparedStatement("my_query", "SELECT 123, 'abc'").build();
    assertQuery(session, "EXECUTE my_query", "SELECT 123, 'abc'");
}
Also used : Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Aggregations

Session (com.facebook.presto.Session)121 Test (org.testng.annotations.Test)61 QueryId (com.facebook.presto.spi.QueryId)21 MaterializedResult (com.facebook.presto.testing.MaterializedResult)20 SemanticException (com.facebook.presto.sql.analyzer.SemanticException)19 PrestoException (com.facebook.presto.spi.PrestoException)17 TransactionManager (com.facebook.presto.transaction.TransactionManager)16 AccessControl (com.facebook.presto.security.AccessControl)15 AllowAllAccessControl (com.facebook.presto.security.AllowAllAccessControl)14 TransactionManager.createTestTransactionManager (com.facebook.presto.transaction.TransactionManager.createTestTransactionManager)14 QualifiedObjectName (com.facebook.presto.metadata.QualifiedObjectName)13 AccessControlManager (com.facebook.presto.security.AccessControlManager)13 ConnectorId (com.facebook.presto.connector.ConnectorId)12 LocalQueryRunner (com.facebook.presto.testing.LocalQueryRunner)12 Type (com.facebook.presto.spi.type.Type)11 List (java.util.List)11 TableHandle (com.facebook.presto.metadata.TableHandle)10 TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)10 Optional (java.util.Optional)10 ColumnHandle (com.facebook.presto.spi.ColumnHandle)9