use of io.prestosql.testing.LocalQueryRunner in project hetu-core by openlookeng.
the class BasePlanTest method createQueryRunner.
private static LocalQueryRunner createQueryRunner(Map<String, String> sessionProperties) {
Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog("local").setSchema("tiny").setSystemProperty("task_concurrency", // these tests don't handle exchanges from local parallel
"1");
sessionProperties.entrySet().forEach(entry -> sessionBuilder.setSystemProperty(entry.getKey(), entry.getValue()));
LocalQueryRunner localQueryRunner = new LocalQueryRunner(sessionBuilder.build());
localQueryRunner.createCatalog(localQueryRunner.getDefaultSession().getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
return localQueryRunner;
}
use of io.prestosql.testing.LocalQueryRunner in project hetu-core by openlookeng.
the class TestRowFilter method init.
@BeforeClass
public void init() {
LocalQueryRunner runner = new LocalQueryRunner(SESSION);
runner.createCatalog(CATALOG, new TpchConnectorFactory(1), ImmutableMap.of());
ConnectorViewDefinition view = new ConnectorViewDefinition("SELECT nationkey, name FROM local.tiny.nation", Optional.empty(), Optional.empty(), ImmutableList.of(new ConnectorViewDefinition.ViewColumn("nationkey", BigintType.BIGINT.getTypeSignature()), new ConnectorViewDefinition.ViewColumn("name", VarcharType.createVarcharType(25).getTypeSignature())), Optional.of(VIEW_OWNER), false);
MockConnectorFactory mock = MockConnectorFactory.builder().withGetViews((s, prefix) -> ImmutableMap.<SchemaTableName, ConnectorViewDefinition>builder().put(new SchemaTableName("default", "nation_view"), view).build()).build();
runner.createCatalog(MOCK_CATALOG, mock, ImmutableMap.of());
assertions = new QueryAssertions(runner);
accessControl = assertions.getQueryRunner().getAccessControl();
}
use of io.prestosql.testing.LocalQueryRunner in project hetu-core by openlookeng.
the class TestQueryContext method testSetMemoryPool.
@Test(dataProvider = "testSetMemoryPoolOptions")
public void testSetMemoryPool(boolean useReservedPool) {
QueryId secondQuery = new QueryId("second");
MemoryPool reservedPool = new MemoryPool(RESERVED_POOL, new DataSize(10, BYTE));
long secondQueryMemory = reservedPool.getMaxBytes() - 1;
if (useReservedPool) {
assertTrue(reservedPool.reserve(secondQuery, "test", secondQueryMemory).isDone());
}
try (LocalQueryRunner localQueryRunner = new LocalQueryRunner(TEST_SESSION)) {
QueryContext queryContext = new QueryContext(new QueryId("query"), new DataSize(10, BYTE), new DataSize(20, BYTE), new MemoryPool(GENERAL_POOL, new DataSize(10, BYTE)), new TestingGcMonitor(), localQueryRunner.getExecutor(), localQueryRunner.getScheduler(), new DataSize(0, BYTE), new SpillSpaceTracker(new DataSize(0, BYTE)), NOOP_SNAPSHOT_UTILS);
// Use memory
queryContext.getQueryMemoryContext().initializeLocalMemoryContexts("test");
LocalMemoryContext userMemoryContext = queryContext.getQueryMemoryContext().localUserMemoryContext();
LocalMemoryContext revocableMemoryContext = queryContext.getQueryMemoryContext().localRevocableMemoryContext();
assertTrue(userMemoryContext.setBytes(3).isDone());
assertTrue(revocableMemoryContext.setBytes(5).isDone());
queryContext.setMemoryPool(reservedPool);
if (useReservedPool) {
reservedPool.free(secondQuery, "test", secondQueryMemory);
}
// Free memory
userMemoryContext.close();
revocableMemoryContext.close();
}
}
use of io.prestosql.testing.LocalQueryRunner in project hetu-core by openlookeng.
the class TestHiddenColumns method setUp.
@BeforeClass
public void setUp() {
runner = new LocalQueryRunner(TEST_SESSION);
runner.createCatalog(TEST_SESSION.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
}
use of io.prestosql.testing.LocalQueryRunner in project hetu-core by openlookeng.
the class MemoryLocalQueryRunner method createMemoryLocalQueryRunner.
private static LocalQueryRunner createMemoryLocalQueryRunner(Session session) {
LocalQueryRunner queryRunnerWithInitialTransaction = LocalQueryRunner.queryRunnerWithInitialTransaction(session);
// add tpch
queryRunnerWithInitialTransaction.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
queryRunnerWithInitialTransaction.createCatalog("memory", new MemoryConnectorFactory(), ImmutableMap.of("memory.max-data-per-node", "4GB"));
return queryRunnerWithInitialTransaction;
}
Aggregations