use of com.facebook.presto.Session in project presto by prestodb.
the class LocalAtopQueryRunner method createQueryRunner.
public static LocalQueryRunner createQueryRunner(Map<String, String> catalogProperties, Class<? extends AtopFactory> factoryClass) throws Exception {
Session session = testSessionBuilder().setCatalog("atop").setSchema("default").setTimeZoneKey(TimeZoneKey.getTimeZoneKey(TimeZone.getDefault().getID())).build();
LocalQueryRunner queryRunner = new LocalQueryRunner(session);
try {
AtopConnectorFactory connectorFactory = new AtopConnectorFactory(factoryClass, LocalAtopQueryRunner.class.getClassLoader());
ImmutableMap.Builder<String, String> properties = ImmutableMap.<String, String>builder().putAll(catalogProperties).put("atop.max-history-days", "1");
queryRunner.createCatalog("atop", connectorFactory, properties.build());
return queryRunner;
} catch (Exception e) {
closeAllSuppress(e, queryRunner);
throw e;
}
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestAtopSecurity method testAdminCanRead.
@Test
public void testAdminCanRead() {
Session admin = getSession("admin");
queryRunner.execute(admin, "SELECT * FROM disks");
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestAtopSecurity method testNonAdminCannotRead.
@Test(expectedExceptions = AccessDeniedException.class)
public void testNonAdminCannotRead() {
Session bob = getSession("bob");
queryRunner.execute(bob, "SELECT * FROM disks");
}
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;
}
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestBlackHoleSmoke method notAllPropertiesSetForDataGeneration.
@Test
public void notAllPropertiesSetForDataGeneration() {
Session session = testSessionBuilder().setCatalog("blackhole").setSchema("default").build();
try {
assertThatQueryReturnsValue(format("CREATE TABLE nation WITH ( %s = 3, %s = 1 ) as SELECT * FROM tpch.tiny.nation", ROWS_PER_PAGE_PROPERTY, SPLIT_COUNT_PROPERTY), 25L, session);
fail("Expected exception to be thrown here!");
} catch (RuntimeException ex) {
// expected exception
}
}
Aggregations