Search in sources :

Example 41 with TpchPlugin

use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.

the class MongoQueryRunner method createMongoQueryRunner.

public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, Map<String, String> extraProperties, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = DistributedQueryRunner.builder(createSession()).setExtraProperties(extraProperties).build();
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        Map<String, String> properties = ImmutableMap.of("mongodb.case-insensitive-name-matching", "true", "mongodb.connection-url", server.getConnectionString().toString());
        queryRunner.installPlugin(new MongoPlugin());
        queryRunner.createCatalog("mongodb", "mongodb", properties);
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner);
        throw e;
    }
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) TpchPlugin(io.trino.plugin.tpch.TpchPlugin)

Example 42 with TpchPlugin

use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.

the class TestRaptorMySqlConnectorTest method createRaptorMySqlQueryRunner.

private static QueryRunner createRaptorMySqlQueryRunner(String mysqlUrl) throws Exception {
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(createSession("tpch")).build();
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    queryRunner.installPlugin(new RaptorPlugin());
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().toFile();
    Map<String, String> raptorProperties = ImmutableMap.<String, String>builder().put("metadata.db.type", "mysql").put("metadata.db.url", mysqlUrl).put("storage.data-directory", new File(baseDir, "data").getAbsolutePath()).put("storage.max-shard-rows", "2000").put("backup.provider", "file").put("backup.directory", new File(baseDir, "backup").getAbsolutePath()).buildOrThrow();
    queryRunner.createCatalog("raptor", "raptor-legacy", raptorProperties);
    copyTables(queryRunner, "tpch", createSession(), false, REQUIRED_TPCH_TABLES);
    return queryRunner;
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) File(java.io.File)

Example 43 with TpchPlugin

use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.

the class PhoenixQueryRunner method createPhoenixQueryRunner.

public static DistributedQueryRunner createPhoenixQueryRunner(TestingPhoenixServer server, Map<String, String> extraProperties, List<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(createSession()).setExtraProperties(extraProperties).build();
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    Map<String, String> properties = ImmutableMap.<String, String>builder().put("phoenix.connection-url", server.getJdbcUrl()).put("case-insensitive-name-matching", "true").buildOrThrow();
    queryRunner.installPlugin(new PhoenixPlugin());
    queryRunner.createCatalog("phoenix", "phoenix", properties);
    if (!server.isTpchLoaded()) {
        createSchema(server, TPCH_SCHEMA);
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
        server.setTpchLoaded();
    } else {
        server.waitTpchLoaded();
    }
    return queryRunner;
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) TpchPlugin(io.trino.plugin.tpch.TpchPlugin)

Example 44 with TpchPlugin

use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.

the class KuduQueryRunnerFactory method createKuduQueryRunnerTpch.

public static QueryRunner createKuduQueryRunnerTpch(TestingKuduServer kuduServer, Optional<String> kuduSchemaEmulationPrefix, Map<String, String> kuduSessionProperties, Map<String, String> extraProperties, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner runner = null;
    try {
        String kuduSchema = kuduSchemaEmulationPrefix.isPresent() ? "tpch" : "default";
        Session session = createSession(kuduSchema, kuduSessionProperties);
        runner = DistributedQueryRunner.builder(session).setExtraProperties(extraProperties).build();
        runner.installPlugin(new TpchPlugin());
        runner.createCatalog("tpch", "tpch");
        installKuduConnector(kuduServer.getMasterAddress(), runner, kuduSchema, kuduSchemaEmulationPrefix);
        copyTpchTables(runner, "tpch", TINY_SCHEMA_NAME, session, tables);
        return runner;
    } catch (Throwable e) {
        closeAllSuppress(e, runner);
        throw e;
    }
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) Session(io.trino.Session)

Example 45 with TpchPlugin

use of io.trino.plugin.tpch.TpchPlugin in project trino by trinodb.

the class PostgreSqlQueryRunner method createPostgreSqlQueryRunner.

public static DistributedQueryRunner createPostgreSqlQueryRunner(TestingPostgreSqlServer server, Map<String, String> extraProperties, Map<String, String> connectorProperties, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = DistributedQueryRunner.builder(createSession()).setExtraProperties(extraProperties).build();
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        connectorProperties = new HashMap<>(ImmutableMap.copyOf(connectorProperties));
        connectorProperties.putIfAbsent("connection-url", server.getJdbcUrl());
        connectorProperties.putIfAbsent("connection-user", server.getUser());
        connectorProperties.putIfAbsent("connection-password", server.getPassword());
        connectorProperties.putIfAbsent("postgresql.include-system-tables", "true");
        // connectorProperties.putIfAbsent("postgresql.experimental.enable-string-pushdown-with-collate", "true");
        queryRunner.installPlugin(new PostgreSqlPlugin());
        queryRunner.createCatalog("postgresql", "postgresql", connectorProperties);
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner, server);
        throw e;
    }
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) TpchPlugin(io.trino.plugin.tpch.TpchPlugin)

Aggregations

TpchPlugin (io.trino.plugin.tpch.TpchPlugin)49 DistributedQueryRunner (io.trino.testing.DistributedQueryRunner)39 Session (io.trino.Session)16 BeforeClass (org.testng.annotations.BeforeClass)8 ImmutableList (com.google.common.collect.ImmutableList)7 ImmutableMap (com.google.common.collect.ImmutableMap)7 QueryRunner (io.trino.testing.QueryRunner)7 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)7 File (java.io.File)7 ImmutableSet (com.google.common.collect.ImmutableSet)6 SchemaTableName (io.trino.spi.connector.SchemaTableName)6 AbstractTestQueryFramework (io.trino.testing.AbstractTestQueryFramework)6 Optional (java.util.Optional)6 Test (org.testng.annotations.Test)6 MockConnectorFactory (io.trino.connector.MockConnectorFactory)5 Plugin (io.trino.spi.Plugin)5 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)4 MockConnectorTableHandle (io.trino.connector.MockConnectorTableHandle)3 BlackHolePlugin (io.trino.plugin.blackhole.BlackHolePlugin)3 BIGINT (io.trino.spi.type.BigintType.BIGINT)3