Search in sources :

Example 6 with QueryRunner

use of io.trino.testing.QueryRunner in project trino by trinodb.

the class KuduQueryRunnerFactory method createKuduQueryRunner.

public static QueryRunner createKuduQueryRunner(TestingKuduServer kuduServer, String kuduSchema) throws Exception {
    QueryRunner runner = null;
    try {
        runner = DistributedQueryRunner.builder(createSession(kuduSchema)).build();
        installKuduConnector(kuduServer.getMasterAddress(), runner, kuduSchema, Optional.of(""));
        return runner;
    } catch (Throwable e) {
        closeAllSuppress(e, runner);
        throw e;
    }
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) QueryRunner(io.trino.testing.QueryRunner)

Example 7 with QueryRunner

use of io.trino.testing.QueryRunner in project trino by trinodb.

the class TestKuduIntegrationDynamicFilter method testIncompleteDynamicFilterTimeout.

@Test(timeOut = 30_000)
public void testIncompleteDynamicFilterTimeout() throws Exception {
    QueryRunner runner = getQueryRunner();
    TransactionManager transactionManager = runner.getTransactionManager();
    TransactionId transactionId = transactionManager.beginTransaction(false);
    Session session = Session.builder(getSession()).setCatalogSessionProperty("kudu", "dynamic_filtering_wait_timeout", "1s").build().beginTransactionId(transactionId, transactionManager, new AllowAllAccessControl());
    QualifiedObjectName tableName = new QualifiedObjectName("kudu", "tpch", "orders");
    Optional<TableHandle> tableHandle = runner.getMetadata().getTableHandle(session, tableName);
    assertTrue(tableHandle.isPresent());
    SplitSource splitSource = runner.getSplitManager().getSplits(session, tableHandle.get(), UNGROUPED_SCHEDULING, new IncompleteDynamicFilter(), alwaysTrue());
    List<Split> splits = new ArrayList<>();
    while (!splitSource.isFinished()) {
        splits.addAll(splitSource.getNextBatch(NOT_PARTITIONED, Lifespan.taskWide(), 1000).get().getSplits());
    }
    splitSource.close();
    assertFalse(splits.isEmpty());
}
Also used : ArrayList(java.util.ArrayList) DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) QueryRunner(io.trino.testing.QueryRunner) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) TransactionId(io.trino.transaction.TransactionId) TransactionManager(io.trino.transaction.TransactionManager) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) TableHandle(io.trino.metadata.TableHandle) SplitSource(io.trino.split.SplitSource) Split(io.trino.metadata.Split) Session(io.trino.Session) Test(org.testng.annotations.Test)

Example 8 with QueryRunner

use of io.trino.testing.QueryRunner 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 9 with QueryRunner

use of io.trino.testing.QueryRunner in project trino by trinodb.

the class TestIcebergQueryFailureRecoveryTest method createQueryRunner.

@Override
protected QueryRunner createQueryRunner(List<TpchTable<?>> requiredTpchTables, Map<String, String> configProperties, Map<String, String> coordinatorProperties) throws Exception {
    this.minioStorage = new MinioStorage("test-exchange-spooling-" + randomTableSuffix());
    minioStorage.start();
    return IcebergQueryRunner.builder().setInitialTables(requiredTpchTables).setCoordinatorProperties(coordinatorProperties).setExtraProperties(configProperties).setAdditionalSetup(runner -> {
        runner.installPlugin(new FileSystemExchangePlugin());
        runner.loadExchangeManager("filesystem", getExchangeManagerProperties(minioStorage));
    }).build();
}
Also used : TpchTable(io.trino.tpch.TpchTable) AfterClass(org.testng.annotations.AfterClass) List(java.util.List) MinioStorage(io.trino.plugin.exchange.containers.MinioStorage) FileSystemExchangePlugin(io.trino.plugin.exchange.FileSystemExchangePlugin) QueryRunner(io.trino.testing.QueryRunner) Map(java.util.Map) RetryPolicy(io.trino.operator.RetryPolicy) TestTable.randomTableSuffix(io.trino.testing.sql.TestTable.randomTableSuffix) MinioStorage.getExchangeManagerProperties(io.trino.plugin.exchange.containers.MinioStorage.getExchangeManagerProperties) MinioStorage(io.trino.plugin.exchange.containers.MinioStorage) FileSystemExchangePlugin(io.trino.plugin.exchange.FileSystemExchangePlugin)

Example 10 with QueryRunner

use of io.trino.testing.QueryRunner 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)

Aggregations

QueryRunner (io.trino.testing.QueryRunner)29 DistributedQueryRunner (io.trino.testing.DistributedQueryRunner)17 ImmutableMap (com.google.common.collect.ImmutableMap)13 Test (org.testng.annotations.Test)13 Session (io.trino.Session)12 ImmutableList (com.google.common.collect.ImmutableList)11 Optional (java.util.Optional)11 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)10 SchemaTableName (io.trino.spi.connector.SchemaTableName)9 AbstractTestQueryFramework (io.trino.testing.AbstractTestQueryFramework)9 List (java.util.List)9 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)8 ImmutableSet (com.google.common.collect.ImmutableSet)7 MockConnectorFactory (io.trino.connector.MockConnectorFactory)7 TpchPlugin (io.trino.plugin.tpch.TpchPlugin)7 MaterializedResult (io.trino.testing.MaterializedResult)7 String.format (java.lang.String.format)7 Map (java.util.Map)6 AfterClass (org.testng.annotations.AfterClass)6 Plugin (io.trino.spi.Plugin)5