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);
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestMemoryManager method testResourceOverCommit.
@Test(timeOut = 240_000)
public void testResourceOverCommit() throws Exception {
Map<String, String> properties = ImmutableMap.<String, String>builder().put("query.max-memory-per-node", "1kB").put("query.max-memory", "1kB").build();
try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) {
try {
queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
fail();
} catch (RuntimeException e) {
// expected
}
Session session = testSessionBuilder().setCatalog("tpch").setSchema("tiny").setSystemProperty(RESOURCE_OVERCOMMIT, "true").build();
queryRunner.execute(session, "SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
}
}
Aggregations