Search in sources :

Example 16 with TpchPlugin

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

the class SingleStoreQueryRunner method createSingleStoreQueryRunner.

public static DistributedQueryRunner createSingleStoreQueryRunner(TestingSingleStoreServer server, Map<String, String> extraProperties, Map<String, String> connectorProperties, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(createSession()).setExtraProperties(extraProperties).build();
    try {
        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.getUsername());
        connectorProperties.putIfAbsent("connection-password", server.getPassword());
        server.execute("CREATE SCHEMA tpch");
        queryRunner.installPlugin(new SingleStorePlugin());
        queryRunner.createCatalog("singlestore", "singlestore", connectorProperties);
        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 17 with TpchPlugin

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

the class ThriftQueryRunner method createThriftQueryRunnerInternal.

private static DistributedQueryRunner createThriftQueryRunnerInternal(List<DriftServer> servers, Map<String, String> properties) throws Exception {
    String addresses = servers.stream().map(server -> "localhost:" + driftServerPort(server)).collect(joining(","));
    Session defaultSession = testSessionBuilder().setCatalog("thrift").setSchema("tiny").build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(defaultSession).setExtraProperties(properties).build();
    queryRunner.installPlugin(new ThriftPlugin());
    Map<String, String> connectorProperties = ImmutableMap.<String, String>builder().put("trino.thrift.client.addresses", addresses).put("trino.thrift.client.connect-timeout", "30s").put("trino-thrift.lookup-requests-concurrency", "2").buildOrThrow();
    queryRunner.createCatalog("thrift", "trino-thrift", connectorProperties);
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    return queryRunner;
}
Also used : NullMethodInvocationStatsFactory(io.airlift.drift.server.stats.NullMethodInvocationStatsFactory) TestingGroupProvider(io.trino.testing.TestingGroupProvider) TransactionManager(io.trino.transaction.TransactionManager) MaterializedResult(io.trino.testing.MaterializedResult) DriftService(io.airlift.drift.server.DriftService) SplitManager(io.trino.split.SplitManager) StatsCalculator(io.trino.cost.StatsCalculator) ThriftTpchService(io.trino.plugin.thrift.server.ThriftTpchService) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) DriftNettyServerConfig(io.airlift.drift.transport.netty.server.DriftNettyServerConfig) ThriftIndexedTpchService(io.trino.plugin.thrift.server.ThriftIndexedTpchService) Map(java.util.Map) TestingAccessControlManager(io.trino.testing.TestingAccessControlManager) ErrorType(io.trino.spi.ErrorType) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) TestingTrinoServer(io.trino.server.testing.TestingTrinoServer) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) InjectedFailureType(io.trino.execution.FailureInjector.InjectedFailureType) Collectors.joining(java.util.stream.Collectors.joining) SessionPropertyManager(io.trino.metadata.SessionPropertyManager) Plugin(io.trino.spi.Plugin) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) DriftNettyServerTransportFactory(io.airlift.drift.transport.netty.server.DriftNettyServerTransportFactory) DriftNettyServerTransport(io.airlift.drift.transport.netty.server.DriftNettyServerTransport) Optional(java.util.Optional) Session(io.trino.Session) ThriftPlugin(io.trino.plugin.thrift.ThriftPlugin) Logger(io.airlift.log.Logger) NodePartitioningManager(io.trino.sql.planner.NodePartitioningManager) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) Closer(com.google.common.io.Closer) QueryExplainer(io.trino.sql.analyzer.QueryExplainer) Objects.requireNonNull(java.util.Objects.requireNonNull) Logging(io.airlift.log.Logging) Closeables.closeAllSuppress(io.airlift.testing.Closeables.closeAllSuppress) DriftServer(io.airlift.drift.server.DriftServer) IOException(java.io.IOException) PageSourceManager(io.trino.split.PageSourceManager) FunctionManager(io.trino.metadata.FunctionManager) FunctionBundle(io.trino.metadata.FunctionBundle) ThriftCodecManager(io.airlift.drift.codec.ThriftCodecManager) Lock(java.util.concurrent.locks.Lock) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) QueryRunner(io.trino.testing.QueryRunner) Metadata(io.trino.metadata.Metadata) TypeManager(io.trino.spi.type.TypeManager) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) ThriftPlugin(io.trino.plugin.thrift.ThriftPlugin) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) Session(io.trino.Session)

Example 18 with TpchPlugin

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

the class TestSharedGlueMetastore method createQueryRunner.

@Override
protected QueryRunner createQueryRunner() throws Exception {
    Session icebergSession = testSessionBuilder().setCatalog(ICEBERG_CATALOG).setSchema(schema).build();
    Session hiveSession = testSessionBuilder().setCatalog(HIVE_CATALOG).setSchema(schema).build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(icebergSession).build();
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    this.dataDirectory = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data");
    this.dataDirectory.toFile().deleteOnExit();
    queryRunner.installPlugin(new IcebergPlugin());
    queryRunner.createCatalog(ICEBERG_CATALOG, "iceberg", ImmutableMap.of("iceberg.catalog.type", "glue", "hive.metastore.glue.default-warehouse-dir", dataDirectory.toString()));
    HdfsConfig hdfsConfig = new HdfsConfig();
    HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of()), hdfsConfig, new NoHdfsAuthentication());
    this.glueMetastore = new GlueHiveMetastore(hdfsEnvironment, new GlueHiveMetastoreConfig(), directExecutor(), new DefaultGlueColumnStatisticsProviderFactory(new GlueHiveMetastoreConfig(), directExecutor(), directExecutor()), Optional.empty(), table -> true);
    queryRunner.installPlugin(new TestingHivePlugin(glueMetastore));
    queryRunner.createCatalog(HIVE_CATALOG, "hive");
    queryRunner.createCatalog("hive_with_redirections", "hive", ImmutableMap.of("hive.iceberg-catalog-name", "iceberg"));
    queryRunner.execute("CREATE SCHEMA " + schema + " WITH (location = '" + dataDirectory.toString() + "')");
    copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, icebergSession, ImmutableList.of(TpchTable.NATION));
    copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, hiveSession, ImmutableList.of(TpchTable.REGION));
    return queryRunner;
}
Also used : Logger(io.airlift.log.Logger) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert.assertEquals(org.testng.Assert.assertEquals) Test(org.testng.annotations.Test) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) AbstractTestQueryFramework(io.trino.testing.AbstractTestQueryFramework) GlueHiveMetastoreConfig(io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig) HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) QueryAssertions.copyTpchTables(io.trino.testing.QueryAssertions.copyTpchTables) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) Path(java.nio.file.Path) TestTable.randomTableSuffix(io.trino.testing.sql.TestTable.randomTableSuffix) TpchTable(io.trino.tpch.TpchTable) AfterClass(org.testng.annotations.AfterClass) TINY_SCHEMA_NAME(io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME) ImmutableSet(com.google.common.collect.ImmutableSet) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) ImmutableMap(com.google.common.collect.ImmutableMap) String.format(java.lang.String.format) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) DefaultGlueColumnStatisticsProviderFactory(io.trino.plugin.hive.metastore.glue.DefaultGlueColumnStatisticsProviderFactory) ICEBERG_CATALOG(io.trino.plugin.iceberg.IcebergQueryRunner.ICEBERG_CATALOG) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) GlueHiveMetastore(io.trino.plugin.hive.metastore.glue.GlueHiveMetastore) HdfsConfig(io.trino.plugin.hive.HdfsConfig) QueryRunner(io.trino.testing.QueryRunner) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) TestingHivePlugin(io.trino.plugin.hive.TestingHivePlugin) Optional(java.util.Optional) Session(io.trino.Session) HdfsConfigurationInitializer(io.trino.plugin.hive.HdfsConfigurationInitializer) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) HiveHdfsConfiguration(io.trino.plugin.hive.HiveHdfsConfiguration) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) TestingHivePlugin(io.trino.plugin.hive.TestingHivePlugin) HdfsConfig(io.trino.plugin.hive.HdfsConfig) NoHdfsAuthentication(io.trino.plugin.hive.authentication.NoHdfsAuthentication) DefaultGlueColumnStatisticsProviderFactory(io.trino.plugin.hive.metastore.glue.DefaultGlueColumnStatisticsProviderFactory) HdfsEnvironment(io.trino.plugin.hive.HdfsEnvironment) GlueHiveMetastore(io.trino.plugin.hive.metastore.glue.GlueHiveMetastore) GlueHiveMetastoreConfig(io.trino.plugin.hive.metastore.glue.GlueHiveMetastoreConfig) Session(io.trino.Session)

Example 19 with TpchPlugin

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

the class TestIcebergMetadataFileOperations method createQueryRunner.

@Override
protected DistributedQueryRunner createQueryRunner() throws Exception {
    Session session = testSessionBuilder().setCatalog("iceberg").setSchema("test_schema").build();
    DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(1).build();
    File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").toFile();
    HiveMetastore metastore = createTestingFileHiveMetastore(baseDir);
    trackingFileIoProvider = new TrackingFileIoProvider(new HdfsFileIoProvider(HDFS_ENVIRONMENT));
    queryRunner.installPlugin(new TestingIcebergPlugin(Optional.of(metastore), Optional.of(trackingFileIoProvider), EMPTY_MODULE));
    queryRunner.createCatalog("iceberg", "iceberg");
    queryRunner.installPlugin(new TpchPlugin());
    queryRunner.createCatalog("tpch", "tpch");
    queryRunner.execute("CREATE SCHEMA test_schema");
    copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, session, TpchTable.getTables());
    return queryRunner;
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) FileHiveMetastore.createTestingFileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore) TpchPlugin(io.trino.plugin.tpch.TpchPlugin) File(java.io.File) Session(io.trino.Session)

Example 20 with TpchPlugin

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

the class OracleQueryRunner method createOracleQueryRunner.

public static DistributedQueryRunner createOracleQueryRunner(TestingOracleServer 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");
        queryRunner.installPlugin(new OraclePlugin());
        queryRunner.createCatalog("oracle", "oracle", 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