Search in sources :

Example 6 with RemoteSourceNode

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

the class PlanUtils method createAggregationFragment.

static PlanFragment createAggregationFragment(String name, PlanFragment sourceFragment) {
    RemoteSourceNode source = new RemoteSourceNode(new PlanNodeId("source_id"), sourceFragment.getId(), ImmutableList.of(), Optional.empty(), REPARTITION, RetryPolicy.NONE);
    PlanNode planNode = new AggregationNode(new PlanNodeId(name + "_id"), source, ImmutableMap.of(), singleGroupingSet(ImmutableList.of()), ImmutableList.of(), FINAL, Optional.empty(), 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) AggregationNode(io.trino.sql.planner.plan.AggregationNode)

Example 7 with RemoteSourceNode

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

the class PlanUtils method createBroadcastAndPartitionedJoinPlanFragment.

static PlanFragment createBroadcastAndPartitionedJoinPlanFragment(String name, PlanFragment broadcastBuildFragment, PlanFragment partitionedBuildFragment, PlanFragment probeFragment) {
    RemoteSourceNode probe = new RemoteSourceNode(new PlanNodeId("probe_id"), probeFragment.getId(), ImmutableList.of(), Optional.empty(), REPARTITION, RetryPolicy.NONE);
    RemoteSourceNode broadcastBuild = new RemoteSourceNode(new PlanNodeId("broadcast_build_id"), broadcastBuildFragment.getId(), ImmutableList.of(), Optional.empty(), REPLICATE, RetryPolicy.NONE);
    RemoteSourceNode partitionedBuild = new RemoteSourceNode(new PlanNodeId("partitioned_build_id"), partitionedBuildFragment.getId(), ImmutableList.of(), Optional.empty(), REPARTITION, RetryPolicy.NONE);
    PlanNode broadcastPlanNode = new JoinNode(new PlanNodeId(name + "_broadcast_id"), INNER, probe, broadcastBuild, ImmutableList.of(), probe.getOutputSymbols(), broadcastBuild.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(REPLICATED), Optional.empty(), ImmutableMap.of(), Optional.empty());
    PlanNode partitionedPlanNode = new JoinNode(new PlanNodeId(name + "_partitioned_id"), INNER, broadcastPlanNode, partitionedBuild, ImmutableList.of(), broadcastPlanNode.getOutputSymbols(), partitionedBuild.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(PARTITIONED), Optional.empty(), ImmutableMap.of(), Optional.empty());
    return createFragment(partitionedPlanNode);
}
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 8 with RemoteSourceNode

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

the class TestFaultTolerantStageScheduler method createPlanFragment.

private PlanFragment createPlanFragment() {
    Symbol probeColumnSymbol = new Symbol("probe_column");
    Symbol buildColumnSymbol = new Symbol("build_column");
    TableScanNode tableScan = new TableScanNode(TABLE_SCAN_NODE_ID, TEST_TABLE_HANDLE, ImmutableList.of(probeColumnSymbol), ImmutableMap.of(probeColumnSymbol, new TestingColumnHandle("column")), TupleDomain.none(), Optional.empty(), false, Optional.empty());
    RemoteSourceNode remoteSource = new RemoteSourceNode(new PlanNodeId("remote_source_id"), ImmutableList.of(SOURCE_FRAGMENT_ID_1, SOURCE_FRAGMENT_ID_2), ImmutableList.of(buildColumnSymbol), Optional.empty(), REPLICATE, TASK);
    return new PlanFragment(FRAGMENT_ID, new JoinNode(new PlanNodeId("join_id"), INNER, tableScan, remoteSource, ImmutableList.of(), tableScan.getOutputSymbols(), remoteSource.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(REPLICATED), Optional.empty(), ImmutableMap.of(), Optional.empty()), ImmutableMap.of(probeColumnSymbol, VARCHAR, buildColumnSymbol, VARCHAR), SOURCE_DISTRIBUTION, ImmutableList.of(TABLE_SCAN_NODE_ID), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), ImmutableList.of(probeColumnSymbol, buildColumnSymbol)), ungroupedExecution(), StatsAndCosts.empty(), Optional.empty());
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) TestingColumnHandle(io.trino.testing.TestingMetadata.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) PlanFragment(io.trino.sql.planner.PlanFragment)

Example 9 with RemoteSourceNode

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

the class TestingTaskSourceFactory method getHandlesForRemoteSources.

private static ListMultimap<PlanNodeId, ExchangeSourceHandle> getHandlesForRemoteSources(List<RemoteSourceNode> remoteSources, Multimap<PlanFragmentId, ExchangeSourceHandle> exchangeSourceHandles) {
    ImmutableListMultimap.Builder<PlanNodeId, ExchangeSourceHandle> result = ImmutableListMultimap.builder();
    for (RemoteSourceNode remoteSource : remoteSources) {
        checkArgument(remoteSource.getExchangeType() == REPLICATE, "expected exchange type to be REPLICATE, got: %s", remoteSource.getExchangeType());
        for (PlanFragmentId fragmentId : remoteSource.getSourceFragmentIds()) {
            Collection<ExchangeSourceHandle> handles = requireNonNull(exchangeSourceHandles.get(fragmentId), () -> "exchange source handle is missing for fragment: " + fragmentId);
            checkArgument(handles.size() == 1, "single 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 10 with RemoteSourceNode

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

the class PlanUtils method createBroadcastJoinPlanFragment.

static PlanFragment createBroadcastJoinPlanFragment(String name, PlanFragment buildFragment) {
    Symbol symbol = new Symbol("column");
    PlanNode tableScan = TableScanNode.newInstance(new PlanNodeId(name), TEST_TABLE_HANDLE, ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingMetadata.TestingColumnHandle("column")), false, Optional.empty());
    RemoteSourceNode remote = new RemoteSourceNode(new PlanNodeId("build_id"), buildFragment.getId(), ImmutableList.of(), Optional.empty(), REPLICATE, RetryPolicy.NONE);
    PlanNode join = new JoinNode(new PlanNodeId(name + "_id"), INNER, tableScan, remote, ImmutableList.of(), tableScan.getOutputSymbols(), remote.getOutputSymbols(), false, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(REPLICATED), Optional.empty(), ImmutableMap.of(), Optional.empty());
    return createFragment(join);
}
Also used : PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) RemoteSourceNode(io.trino.sql.planner.plan.RemoteSourceNode) PlanNode(io.trino.sql.planner.plan.PlanNode) Symbol(io.trino.sql.planner.Symbol) JoinNode(io.trino.sql.planner.plan.JoinNode)

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