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");
}
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestDistributedQueriesIndexed method createQueryRunner.
private static DistributedQueryRunner createQueryRunner() throws Exception {
Session session = testSessionBuilder().setCatalog("tpch_indexed").setSchema(TINY_SCHEMA_NAME).build();
DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 3);
queryRunner.installPlugin(new IndexedTpchPlugin(INDEX_SPEC));
queryRunner.createCatalog("tpch_indexed", "tpch_indexed");
return queryRunner;
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestLocalBinarySpilledQueries method createLocalQueryRunner.
private static LocalQueryRunner createLocalQueryRunner() {
Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).setSystemProperty(SystemSessionProperties.SPILL_ENABLED, "true").setSystemProperty(SystemSessionProperties.OPERATOR_MEMORY_LIMIT_BEFORE_SPILL, //spill constantly
"1B").build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
// add the tpch catalog
// local queries run directly against the generator
localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);
SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
sessionPropertyManager.addConnectorSessionProperties(new ConnectorId(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
return localQueryRunner;
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestLocalQueries method createLocalQueryRunner.
public static LocalQueryRunner createLocalQueryRunner() {
Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).setSystemProperty(REORDER_JOINS, "true").build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
// add the tpch catalog
// local queries run directly against the generator
localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);
SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
sessionPropertyManager.addConnectorSessionProperties(new ConnectorId(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
return localQueryRunner;
}
use of com.facebook.presto.Session in project presto by prestodb.
the class MemoryLocalQueryRunner method execute.
public void execute(@Language("SQL") String query) {
Session session = testSessionBuilder().setSystemProperty("optimizer.optimize-hash-generation", "true").build();
ExecutorService executor = localQueryRunner.getExecutor();
MemoryPool memoryPool = new MemoryPool(new MemoryPoolId("test"), new DataSize(1, GIGABYTE));
MemoryPool systemMemoryPool = new MemoryPool(new MemoryPoolId("testSystem"), new DataSize(1, GIGABYTE));
TaskContext taskContext = new QueryContext(new QueryId("test"), new DataSize(256, MEGABYTE), memoryPool, systemMemoryPool, executor).addTaskContext(new TaskStateMachine(new TaskId("query", 0, 0), executor), session, false, false);
// Use NullOutputFactory to avoid coping out results to avoid affecting benchmark results
List<Driver> drivers = localQueryRunner.createDrivers(query, new NullOutputOperator.NullOutputFactory(), taskContext);
boolean done = false;
while (!done) {
boolean processed = false;
for (Driver driver : drivers) {
if (!driver.isFinished()) {
driver.process();
processed = true;
}
}
done = !processed;
}
}
Aggregations