Search in sources :

Example 1 with TPCH_SPLITS_PER_NODE

use of io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE in project trino by trinodb.

the class TestEventListenerWithSplits method createQueryRunner.

@Override
protected QueryRunner createQueryRunner() throws Exception {
    Session session = testSessionBuilder().setSystemProperty("task_concurrency", "1").setCatalog("tpch").setSchema("tiny").setClientInfo("{\"clientVersion\":\"testVersion\"}").build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(1).build();
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.installPlugin(new TestingEventListenerPlugin(generatedEvents));
    queryRunner.installPlugin(new ResourceGroupManagerPlugin());
    queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, Integer.toString(SPLITS_PER_NODE)));
    queryRunner.installPlugin(new Plugin() {

        @Override
        public Iterable<ConnectorFactory> getConnectorFactories() {
            MockConnectorFactory connectorFactory = MockConnectorFactory.builder().withListTables((session, s) -> ImmutableList.of(new SchemaTableName("default", "test_table"))).withApplyProjection((session, handle, projections, assignments) -> {
                throw new RuntimeException("Throw from apply projection");
            }).build();
            return ImmutableList.of(connectorFactory);
        }
    });
    queryRunner.createCatalog("mock", "mock", ImmutableMap.of());
    queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_simple.json")));
    queries = new EventsAwaitingQueries(generatedEvents, queryRunner, Duration.ofSeconds(1));
    return queryRunner;
}
Also used : TestingEventListenerPlugin(io.trino.execution.TestEventListenerPlugin.TestingEventListenerPlugin) QueryCompletedEvent(io.trino.spi.eventlistener.QueryCompletedEvent) MaterializedResult(io.trino.testing.MaterializedResult) QueryCreatedEvent(io.trino.spi.eventlistener.QueryCreatedEvent) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) TPCH_SPLITS_PER_NODE(io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE) AbstractTestQueryFramework(io.trino.testing.AbstractTestQueryFramework) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) ImmutableList(com.google.common.collect.ImmutableList) MockConnectorFactory(io.trino.connector.MockConnectorFactory) Duration(java.time.Duration) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) Assert.assertFalse(org.testng.Assert.assertFalse) Collectors.toSet(java.util.stream.Collectors.toSet) QueryStatistics(io.trino.spi.eventlistener.QueryStatistics) SplitCompletedEvent(io.trino.spi.eventlistener.SplitCompletedEvent) ImmutableSet(com.google.common.collect.ImmutableSet) TestingEventListenerPlugin(io.trino.execution.TestEventListenerPlugin.TestingEventListenerPlugin) QueryType(io.trino.spi.resourcegroups.QueryType) ImmutableMap(com.google.common.collect.ImmutableMap) ResourceGroupManagerPlugin(io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin) Language(org.intellij.lang.annotations.Language) Set(java.util.Set) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) SchemaTableName(io.trino.spi.connector.SchemaTableName) Plugin(io.trino.spi.Plugin) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) TestQueues.createResourceGroupId(io.trino.execution.TestQueues.createResourceGroupId) QueryRunner(io.trino.testing.QueryRunner) Optional(java.util.Optional) Assert.assertTrue(org.testng.Assert.assertTrue) Session(io.trino.Session) MockConnectorFactory(io.trino.connector.MockConnectorFactory) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) SchemaTableName(io.trino.spi.connector.SchemaTableName) ResourceGroupManagerPlugin(io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin) Session(io.trino.Session) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) TestingEventListenerPlugin(io.trino.execution.TestEventListenerPlugin.TestingEventListenerPlugin) ResourceGroupManagerPlugin(io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin) Plugin(io.trino.spi.Plugin)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)1 Session (io.trino.Session)1 MockConnectorFactory (io.trino.connector.MockConnectorFactory)1 TestingEventListenerPlugin (io.trino.execution.TestEventListenerPlugin.TestingEventListenerPlugin)1 TestQueues.createResourceGroupId (io.trino.execution.TestQueues.createResourceGroupId)1 ResourceGroupManagerPlugin (io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin)1 TPCH_SPLITS_PER_NODE (io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE)1 TpchPlugin (io.trino.plugin.tpch.TpchPlugin)1 Plugin (io.trino.spi.Plugin)1 ConnectorFactory (io.trino.spi.connector.ConnectorFactory)1 SchemaTableName (io.trino.spi.connector.SchemaTableName)1 QueryCompletedEvent (io.trino.spi.eventlistener.QueryCompletedEvent)1 QueryCreatedEvent (io.trino.spi.eventlistener.QueryCreatedEvent)1 QueryStatistics (io.trino.spi.eventlistener.QueryStatistics)1 SplitCompletedEvent (io.trino.spi.eventlistener.SplitCompletedEvent)1 QueryType (io.trino.spi.resourcegroups.QueryType)1 AbstractTestQueryFramework (io.trino.testing.AbstractTestQueryFramework)1