use of com.facebook.presto.Session in project presto by prestodb.
the class AbstractTestQueries method testDescribeOutputShowTables.
@Test
public void testDescribeOutputShowTables() {
Session session = Session.builder(getSession()).addPreparedStatement("my_query", "SHOW TABLES").build();
MaterializedResult actual = computeActual(session, "DESCRIBE OUTPUT my_query");
MaterializedResult expected = resultBuilder(session, VARCHAR, VARCHAR, VARCHAR, VARCHAR, VARCHAR, BIGINT, BOOLEAN).row("Table", session.getCatalog().get(), "information_schema", "tables", "varchar", 0, true).build();
assertEqualsIgnoreOrder(actual, expected);
}
use of com.facebook.presto.Session in project presto by prestodb.
the class AbstractTestQueries method testExplainSetSessionWithUsing.
@Test
public void testExplainSetSessionWithUsing() {
Session session = Session.builder(getSession()).addPreparedStatement("my_query", "SET SESSION foo = ?").build();
MaterializedResult result = computeActual(session, "EXPLAIN (TYPE LOGICAL) EXECUTE my_query USING 7");
assertEquals(getOnlyElement(result.getOnlyColumnAsSet()), "SET SESSION foo = 7");
}
use of com.facebook.presto.Session in project presto by prestodb.
the class AbstractTestQueries method testDescribeInputNoParameters.
@Test
public void testDescribeInputNoParameters() {
Session session = Session.builder(getSession()).addPreparedStatement("my_query", "select * from nation").build();
MaterializedResult actual = computeActual(session, "DESCRIBE INPUT my_query");
MaterializedResult expected = resultBuilder(session, BIGINT, VARCHAR).build();
assertEquals(actual, expected);
}
use of com.facebook.presto.Session in project presto by prestodb.
the class AbstractTestQueries method testExecuteWithParametersInGroupBy.
@Test
public void testExecuteWithParametersInGroupBy() {
try {
String query = "SELECT a + ?, count(1) FROM (VALUES 1, 2, 3, 2) t(a) GROUP BY a + ?";
Session session = Session.builder(getSession()).addPreparedStatement("my_query", query).build();
computeActual(session, "EXECUTE my_query USING 1, 1");
fail("parameters in group by and select should fail");
} catch (SemanticException e) {
assertEquals(e.getCode(), MUST_BE_AGGREGATE_OR_GROUP_BY);
} catch (RuntimeException e) {
assertEquals(e.getMessage(), "line 1:10: '(\"a\" + ?)' must be an aggregate expression or appear in GROUP BY clause");
}
}
use of com.facebook.presto.Session in project presto by prestodb.
the class AbstractTestQueries method assertDescribeOutputRowCount.
private void assertDescribeOutputRowCount(@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).row("rows", "", "", "", "bigint", 8, false).build();
assertEqualsIgnoreOrder(actual, expected);
}
Aggregations