Search in sources :

Example 11 with RemoteSourceNode

use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.

the class TestDynamicFilterService method createPlan.

private static PlanFragment createPlan(DynamicFilterId consumedDynamicFilterId, DynamicFilterId producedDynamicFilterId, PartitioningHandle stagePartitioning, ExchangeNode.Type exchangeType) {
    Symbol symbol = new Symbol("column");
    Symbol buildSymbol = new Symbol("buildColumn");
    PlanNodeId tableScanNodeId = new PlanNodeId("plan_id");
    TableScanNode tableScan = TableScanNode.newInstance(tableScanNodeId, TEST_TABLE_HANDLE, ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingMetadata.TestingColumnHandle("column")), false, Optional.empty());
    FilterNode filterNode = new FilterNode(new PlanNodeId("filter_node_id"), tableScan, createDynamicFilterExpression(session, createTestMetadataManager(), consumedDynamicFilterId, VARCHAR, symbol.toSymbolReference()));
    RemoteSourceNode remote = new RemoteSourceNode(new PlanNodeId("remote_id"), new PlanFragmentId("plan_fragment_id"), ImmutableList.of(buildSymbol), Optional.empty(), exchangeType, RetryPolicy.NONE);
    return new PlanFragment(new PlanFragmentId("plan_id"), new JoinNode(new PlanNodeId("join_id"), INNER, filterNode, remote, ImmutableList.of(), tableScan.getOutputSymbols(), remote.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableMap.of(producedDynamicFilterId, buildSymbol), Optional.empty()), ImmutableMap.of(symbol, VARCHAR), stagePartitioning, ImmutableList.of(tableScanNodeId), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), ImmutableList.of(symbol)), ungroupedExecution(), StatsAndCosts.empty(), Optional.empty());
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) TestingColumnHandle(io.trino.spi.connector.TestingColumnHandle) RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) TableScanNode(io.trino.sql.planner.plan.TableScanNode) Symbol(io.trino.sql.planner.Symbol) JoinNode(io.trino.sql.planner.plan.JoinNode) PartitioningScheme(io.trino.sql.planner.PartitioningScheme) FilterNode(io.trino.sql.planner.plan.FilterNode) PlanFragmentId(io.trino.sql.planner.plan.PlanFragmentId) PlanFragment(io.trino.sql.planner.PlanFragment)

Example 12 with RemoteSourceNode

use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.

the class PlanUtils method createJoinPlanFragment.

static PlanFragment createJoinPlanFragment(JoinNode.Type joinType, JoinNode.DistributionType distributionType, String name, PlanFragment buildFragment, PlanFragment probeFragment) {
    RemoteSourceNode probe = new RemoteSourceNode(new PlanNodeId("probe_id"), probeFragment.getId(), ImmutableList.of(), Optional.empty(), REPARTITION, RetryPolicy.NONE);
    RemoteSourceNode build = new RemoteSourceNode(new PlanNodeId("build_id"), buildFragment.getId(), ImmutableList.of(), Optional.empty(), REPARTITION, RetryPolicy.NONE);
    PlanNode planNode = new JoinNode(new PlanNodeId(name + "_id"), joinType, probe, build, ImmutableList.of(), probe.getOutputSymbols(), build.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(distributionType), Optional.empty(), ImmutableMap.of(), Optional.empty());
    return createFragment(planNode);
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) PlanNode(io.trino.sql.planner.plan.PlanNode) JoinNode(io.trino.sql.planner.plan.JoinNode)

Example 13 with RemoteSourceNode

use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.

the class StageTaskSourceFactory method getInputsForRemoteSources.

private static ListMultimap<PlanNodeId, ExchangeSourceHandle> getInputsForRemoteSources(List<RemoteSourceNode> remoteSources, Multimap<PlanFragmentId, ExchangeSourceHandle> exchangeSourceHandles) {
    ImmutableListMultimap.Builder<PlanNodeId, ExchangeSourceHandle> result = ImmutableListMultimap.builder();
    for (RemoteSourceNode remoteSource : remoteSources) {
        for (PlanFragmentId fragmentId : remoteSource.getSourceFragmentIds()) {
            Collection<ExchangeSourceHandle> handles = requireNonNull(exchangeSourceHandles.get(fragmentId), () -> "exchange source handle is missing for fragment: " + fragmentId);
            if (remoteSource.getExchangeType() == GATHER || remoteSource.getExchangeType() == REPLICATE) {
                checkArgument(handles.size() <= 1, "at most 1 exchange source handle is expected, got: %s", handles);
            }
            result.putAll(remoteSource.getId(), handles);
        }
    }
    return result.build();
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) ExchangeSourceHandle(io.trino.spi.exchange.ExchangeSourceHandle) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) PlanFragmentId(io.trino.sql.planner.plan.PlanFragmentId)

Example 14 with RemoteSourceNode

use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.

the class PipelinedStageExecution method createPipelinedStageExecution.

public static PipelinedStageExecution createPipelinedStageExecution(SqlStage stage, Map<PlanFragmentId, OutputBufferManager> outputBufferManagers, TaskLifecycleListener taskLifecycleListener, FailureDetector failureDetector, Executor executor, Optional<int[]> bucketToPartition, int attempt) {
    PipelinedStageStateMachine stateMachine = new PipelinedStageStateMachine(stage.getStageId(), executor);
    ImmutableMap.Builder<PlanFragmentId, RemoteSourceNode> exchangeSources = ImmutableMap.builder();
    for (RemoteSourceNode remoteSourceNode : stage.getFragment().getRemoteSourceNodes()) {
        for (PlanFragmentId planFragmentId : remoteSourceNode.getSourceFragmentIds()) {
            exchangeSources.put(planFragmentId, remoteSourceNode);
        }
    }
    PipelinedStageExecution execution = new PipelinedStageExecution(stateMachine, stage, outputBufferManagers, taskLifecycleListener, failureDetector, executor, bucketToPartition, exchangeSources.buildOrThrow(), attempt);
    execution.initialize();
    return execution;
}
Also used : RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) PlanFragmentId(io.trino.sql.planner.plan.PlanFragmentId) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 15 with RemoteSourceNode

use of io.trino.sql.planner.plan.RemoteSourceNode in project trino by trinodb.

the class PipelinedStageExecution method noMoreSourceTasks.

private synchronized void noMoreSourceTasks(PlanFragmentId fragmentId) {
    RemoteSourceNode remoteSource = exchangeSources.get(fragmentId);
    checkArgument(remoteSource != null, "Unknown remote source %s. Known sources are %s", fragmentId, exchangeSources.keySet());
    completeSourceFragments.add(fragmentId);
    // is the source now complete?
    if (completeSourceFragments.containsAll(remoteSource.getSourceFragmentIds())) {
        completeSources.add(remoteSource.getId());
        for (RemoteTask task : getAllTasks()) {
            task.noMoreSplits(remoteSource.getId());
        }
    }
}
Also used : RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) RemoteTask(io.trino.execution.RemoteTask)

Aggregations

RemoteSourceNode (io.trino.sql.planner.plan.RemoteSourceNode)15 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)11 PlanFragmentId (io.trino.sql.planner.plan.PlanFragmentId)8 JoinNode (io.trino.sql.planner.plan.JoinNode)7 PlanNode (io.trino.sql.planner.plan.PlanNode)6 PlanFragment (io.trino.sql.planner.PlanFragment)5 Symbol (io.trino.sql.planner.Symbol)5 PartitioningScheme (io.trino.sql.planner.PartitioningScheme)4 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 RemoteTask (io.trino.execution.RemoteTask)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 ExchangeSourceHandle (io.trino.spi.exchange.ExchangeSourceHandle)2 TableScanNode (io.trino.sql.planner.plan.TableScanNode)2 List (java.util.List)2 Map (java.util.Map)2