Search in sources :

Example 26 with LocalQueryRunner

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

the class TestMetadataQueryOptimization method createLocalQueryRunner.

@Override
protected LocalQueryRunner createLocalQueryRunner() {
    Session session = testSessionBuilder().setCatalog(ICEBERG_CATALOG).setSchema(SCHEMA_NAME).build();
    baseDir = Files.createTempDir();
    HiveMetastore metastore = createTestingFileHiveMetastore(baseDir);
    LocalQueryRunner queryRunner = LocalQueryRunner.create(session);
    queryRunner.createCatalog(ICEBERG_CATALOG, new TestingIcebergConnectorFactory(Optional.of(metastore), Optional.empty(), EMPTY_MODULE), ImmutableMap.of());
    Database database = Database.builder().setDatabaseName(SCHEMA_NAME).setOwnerName(Optional.of("public")).setOwnerType(Optional.of(PrincipalType.ROLE)).build();
    metastore.createDatabase(database);
    return queryRunner;
}
Also used : HiveMetastore(io.trino.plugin.hive.metastore.HiveMetastore) FileHiveMetastore.createTestingFileHiveMetastore(io.trino.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore) Database(io.trino.plugin.hive.metastore.Database) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Session(io.trino.Session)

Example 27 with LocalQueryRunner

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

the class TestThriftProjectionPushdown method createLocalQueryRunner.

@Override
protected Optional<LocalQueryRunner> createLocalQueryRunner() {
    try {
        servers = startThriftServers(1, false);
    } catch (Throwable t) {
        try {
            cleanup();
        } catch (Throwable e) {
            t.addSuppressed(e);
        }
        throw t;
    }
    String addresses = servers.stream().map(server -> "localhost:" + driftServerPort(server)).collect(joining(","));
    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();
    LocalQueryRunner runner = LocalQueryRunner.create(SESSION);
    runner.createCatalog(CATALOG, getOnlyElement(new ThriftPlugin().getConnectorFactories()), connectorProperties);
    return Optional.of(runner);
}
Also used : ThriftTransactionHandle(io.trino.plugin.thrift.ThriftTransactionHandle) Test(org.testng.annotations.Test) ThriftTableHandle(io.trino.plugin.thrift.ThriftTableHandle) CatalogName(io.trino.connector.CatalogName) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) Closer(com.google.common.io.Closer) ConnectorTableHandle(io.trino.spi.connector.ConnectorTableHandle) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Map(java.util.Map) ColumnHandle(io.trino.spi.connector.ColumnHandle) ThriftQueryRunner.startThriftServers(io.trino.plugin.thrift.integration.ThriftQueryRunner.startThriftServers) ThriftColumnHandle(io.trino.plugin.thrift.ThriftColumnHandle) Symbol(io.trino.sql.planner.Symbol) AfterClass(org.testng.annotations.AfterClass) PlanMatchPattern.expression(io.trino.sql.planner.assertions.PlanMatchPattern.expression) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) BaseRuleTest(io.trino.sql.planner.iterative.rule.test.BaseRuleTest) Assignments(io.trino.sql.planner.plan.Assignments) DriftServer(io.airlift.drift.server.DriftServer) IOException(java.io.IOException) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) TupleDomain(io.trino.spi.predicate.TupleDomain) ScalarStatsCalculator(io.trino.cost.ScalarStatsCalculator) SchemaTableName(io.trino.spi.connector.SchemaTableName) Collectors.joining(java.util.stream.Collectors.joining) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) TableHandle(io.trino.metadata.TableHandle) PlanMatchPattern.project(io.trino.sql.planner.assertions.PlanMatchPattern.project) SymbolReference(io.trino.sql.tree.SymbolReference) PushProjectionIntoTableScan(io.trino.sql.planner.iterative.rule.PushProjectionIntoTableScan) PruneTableScanColumns(io.trino.sql.planner.iterative.rule.PruneTableScanColumns) Optional(java.util.Optional) ThriftQueryRunner.driftServerPort(io.trino.plugin.thrift.integration.ThriftQueryRunner.driftServerPort) PlanMatchPattern.tableScan(io.trino.sql.planner.assertions.PlanMatchPattern.tableScan) Session(io.trino.Session) ThriftPlugin(io.trino.plugin.thrift.ThriftPlugin) ThriftPlugin(io.trino.plugin.thrift.ThriftPlugin) LocalQueryRunner(io.trino.testing.LocalQueryRunner)

Example 28 with LocalQueryRunner

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

the class ArrayComparisonBenchmark method main.

public static void main(String... args) {
    LocalQueryRunner localQueryRunner = createLocalQueryRunner();
    new ArrayEqualsBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out));
    new ArrayLessThanBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out));
    new ArrayGreaterThanBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out));
    new ArrayNotEqualBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out));
    new ArrayLessThanOrEqualBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out));
    new ArrayGreaterThanOrEqualBenchmark(localQueryRunner).runBenchmark(new SimpleLineBenchmarkResultWriter(System.out));
}
Also used : LocalQueryRunner(io.trino.testing.LocalQueryRunner) BenchmarkQueryRunner.createLocalQueryRunner(io.trino.benchmark.BenchmarkQueryRunner.createLocalQueryRunner)

Example 29 with LocalQueryRunner

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

the class BenchmarkQueryRunner method createLocalQueryRunner.

public static LocalQueryRunner createLocalQueryRunner(Map<String, String> extraSessionProperties) {
    SessionBuilder sessionBuilder = testSessionBuilder().setCatalog("tpch").setSchema(TINY_SCHEMA_NAME);
    extraSessionProperties.forEach(sessionBuilder::setSystemProperty);
    Session session = sessionBuilder.build();
    LocalQueryRunner localQueryRunner = LocalQueryRunner.create(session);
    // add tpch
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
    return localQueryRunner;
}
Also used : TpchConnectorFactory(io.trino.plugin.tpch.TpchConnectorFactory) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) SessionBuilder(io.trino.Session.SessionBuilder) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Session(io.trino.Session)

Example 30 with LocalQueryRunner

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

the class TestTpcdsCostBasedPlan method createLocalQueryRunner.

/*
     * CAUTION: The expected plans here are not necessarily optimal yet. Their role is to prevent
     * inadvertent regressions. A conscious improvement to the planner may require changing some
     * of the expected plans, but any such change should be verified on an actual cluster with
     * large amount of data.
     */
@Override
protected LocalQueryRunner createLocalQueryRunner() {
    String catalog = "local";
    Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog(catalog).setSchema("sf3000.0").setSystemProperty("task_concurrency", // these tests don't handle exchanges from local parallel
    "1").setSystemProperty(JOIN_REORDERING_STRATEGY, JoinReorderingStrategy.AUTOMATIC.name()).setSystemProperty(JOIN_DISTRIBUTION_TYPE, JoinDistributionType.AUTOMATIC.name());
    LocalQueryRunner queryRunner = LocalQueryRunner.builder(sessionBuilder.build()).withNodeCountForStats(8).build();
    queryRunner.createCatalog(catalog, new TpcdsConnectorFactory(1), ImmutableMap.of());
    return queryRunner;
}
Also used : TpcdsConnectorFactory(io.trino.plugin.tpcds.TpcdsConnectorFactory) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Session(io.trino.Session)

Aggregations

LocalQueryRunner (io.trino.testing.LocalQueryRunner)66 Session (io.trino.Session)28 TpchConnectorFactory (io.trino.plugin.tpch.TpchConnectorFactory)25 Test (org.testng.annotations.Test)22 ImmutableMap (com.google.common.collect.ImmutableMap)12 SchemaTableName (io.trino.spi.connector.SchemaTableName)12 ImmutableList (com.google.common.collect.ImmutableList)11 MockConnectorFactory (io.trino.connector.MockConnectorFactory)11 Optional (java.util.Optional)11 CatalogName (io.trino.connector.CatalogName)9 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)9 MockConnectorTableHandle (io.trino.connector.MockConnectorTableHandle)8 QualifiedObjectName (io.trino.metadata.QualifiedObjectName)8 CatalogSchemaTableName (io.trino.spi.connector.CatalogSchemaTableName)7 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)7 TrinoException (io.trino.spi.TrinoException)6 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 ColumnHandle (io.trino.spi.connector.ColumnHandle)5 List (java.util.List)5