Search in sources :

Example 1 with ThriftPlugin

use of io.trino.plugin.thrift.ThriftPlugin 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 2 with ThriftPlugin

use of io.trino.plugin.thrift.ThriftPlugin 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)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Closer (com.google.common.io.Closer)2 DriftServer (io.airlift.drift.server.DriftServer)2 Session (io.trino.Session)2 ThriftPlugin (io.trino.plugin.thrift.ThriftPlugin)2 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)2 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Collectors.joining (java.util.stream.Collectors.joining)2 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)1 ThriftCodecManager (io.airlift.drift.codec.ThriftCodecManager)1 DriftService (io.airlift.drift.server.DriftService)1 NullMethodInvocationStatsFactory (io.airlift.drift.server.stats.NullMethodInvocationStatsFactory)1 DriftNettyServerConfig (io.airlift.drift.transport.netty.server.DriftNettyServerConfig)1 DriftNettyServerTransport (io.airlift.drift.transport.netty.server.DriftNettyServerTransport)1 DriftNettyServerTransportFactory (io.airlift.drift.transport.netty.server.DriftNettyServerTransportFactory)1