Search in sources :

Example 6 with LocalQueryRunner

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;
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) Session(io.prestosql.Session)

Example 7 with 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();
}
Also used : BigintType(io.prestosql.spi.type.BigintType) AfterClass(org.testng.annotations.AfterClass) ImmutableMap(com.google.common.collect.ImmutableMap) TINY_SCHEMA_NAME(io.prestosql.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME) ConnectorViewDefinition(io.prestosql.spi.connector.ConnectorViewDefinition) BeforeClass(org.testng.annotations.BeforeClass) TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) ViewExpression(io.prestosql.spi.security.ViewExpression) Identity(io.prestosql.spi.security.Identity) Test(org.testng.annotations.Test) MockConnectorFactory(io.prestosql.connector.MockConnectorFactory) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) TestingSession.testSessionBuilder(io.prestosql.testing.TestingSession.testSessionBuilder) TestingAccessControlManager(io.prestosql.testing.TestingAccessControlManager) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) ImmutableList(com.google.common.collect.ImmutableList) Session(io.prestosql.Session) Optional(java.util.Optional) VarcharType(io.prestosql.spi.type.VarcharType) TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) MockConnectorFactory(io.prestosql.connector.MockConnectorFactory) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) ConnectorViewDefinition(io.prestosql.spi.connector.ConnectorViewDefinition) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with LocalQueryRunner

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();
    }
}
Also used : LocalMemoryContext(io.prestosql.memory.context.LocalMemoryContext) SpillSpaceTracker(io.prestosql.spiller.SpillSpaceTracker) QueryId(io.prestosql.spi.QueryId) DataSize(io.airlift.units.DataSize) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) Test(org.testng.annotations.Test)

Example 9 with LocalQueryRunner

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());
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner) BeforeClass(org.testng.annotations.BeforeClass)

Example 10 with LocalQueryRunner

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;
}
Also used : TpchConnectorFactory(io.prestosql.plugin.tpch.TpchConnectorFactory) MemoryConnectorFactory(io.prestosql.plugin.memory.MemoryConnectorFactory) LocalQueryRunner(io.prestosql.testing.LocalQueryRunner)

Aggregations

LocalQueryRunner (io.prestosql.testing.LocalQueryRunner)29 TpchConnectorFactory (io.prestosql.plugin.tpch.TpchConnectorFactory)20 Session (io.prestosql.Session)15 BeforeClass (org.testng.annotations.BeforeClass)9 File (java.io.File)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 FeaturesConfig (io.prestosql.sql.analyzer.FeaturesConfig)3 TestingSession.testSessionBuilder (io.prestosql.testing.TestingSession.testSessionBuilder)3 Test (org.testng.annotations.Test)3 ImmutableList (com.google.common.collect.ImmutableList)2 HetuFileSystemClientPlugin (io.hetu.core.filesystem.HetuFileSystemClientPlugin)2 BenchmarkQueryRunner.createLocalQueryRunner (io.prestosql.benchmark.BenchmarkQueryRunner.createLocalQueryRunner)2 BenchmarkSuite (io.prestosql.benchmark.BenchmarkSuite)2 MockConnectorFactory (io.prestosql.connector.MockConnectorFactory)2 SessionPropertyManager (io.prestosql.metadata.SessionPropertyManager)2 HiveIdentity (io.prestosql.plugin.hive.authentication.HiveIdentity)2 HiveMetastore (io.prestosql.plugin.hive.metastore.HiveMetastore)2 FileHiveMetastore.createTestingFileHiveMetastore (io.prestosql.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore)2 MemoryConnectorFactory (io.prestosql.plugin.memory.MemoryConnectorFactory)2 TINY_SCHEMA_NAME (io.prestosql.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME)2