Search in sources :

Example 56 with JoinNode

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

the class LocalDynamicFilterConsumer method create.

public static LocalDynamicFilterConsumer create(JoinNode planNode, List<Type> buildSourceTypes, int partitionCount, Set<DynamicFilterId> collectedFilters) {
    checkArgument(!planNode.getDynamicFilters().isEmpty(), "Join node dynamicFilters is empty.");
    checkArgument(!collectedFilters.isEmpty(), "Collected dynamic filters set is empty");
    checkArgument(planNode.getDynamicFilters().keySet().containsAll(collectedFilters), "Collected dynamic filters set is not subset of join dynamic filters");
    PlanNode buildNode = planNode.getRight();
    Map<DynamicFilterId, Integer> buildChannels = planNode.getDynamicFilters().entrySet().stream().filter(entry -> collectedFilters.contains(entry.getKey())).collect(toImmutableMap(// Dynamic filter ID
    Map.Entry::getKey, // Build-side channel index
    entry -> {
        Symbol buildSymbol = entry.getValue();
        int buildChannelIndex = buildNode.getOutputSymbols().indexOf(buildSymbol);
        verify(buildChannelIndex >= 0);
        return buildChannelIndex;
    }));
    Map<DynamicFilterId, Type> filterBuildTypes = buildChannels.entrySet().stream().collect(toImmutableMap(Map.Entry::getKey, entry -> buildSourceTypes.get(entry.getValue())));
    return new LocalDynamicFilterConsumer(buildChannels, filterBuildTypes, partitionCount);
}
Also used : ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ImmutableMap(com.google.common.collect.ImmutableMap) Domain(io.trino.spi.predicate.Domain) Type(io.trino.spi.type.Type) Set(java.util.Set) HashMap(java.util.HashMap) SettableFuture(com.google.common.util.concurrent.SettableFuture) TupleDomain(io.trino.spi.predicate.TupleDomain) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId) PlanNode(io.trino.sql.planner.plan.PlanNode) ArrayList(java.util.ArrayList) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) Consumer(java.util.function.Consumer) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) Verify.verify(com.google.common.base.Verify.verify) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Function.identity(java.util.function.Function.identity) JoinNode(io.trino.sql.planner.plan.JoinNode) MoreObjects.toStringHelper(com.google.common.base.MoreObjects.toStringHelper) Type(io.trino.spi.type.Type) PlanNode(io.trino.sql.planner.plan.PlanNode) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) Map(java.util.Map) DynamicFilterId(io.trino.sql.planner.plan.DynamicFilterId)

Aggregations

JoinNode (io.trino.sql.planner.plan.JoinNode)56 Symbol (io.trino.sql.planner.Symbol)35 PlanNode (io.trino.sql.planner.plan.PlanNode)34 Expression (io.trino.sql.tree.Expression)22 Test (org.testng.annotations.Test)22 TableScanNode (io.trino.sql.planner.plan.TableScanNode)17 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)16 FilterNode (io.trino.sql.planner.plan.FilterNode)15 ComparisonExpression (io.trino.sql.tree.ComparisonExpression)15 ImmutableList (com.google.common.collect.ImmutableList)14 ProjectNode (io.trino.sql.planner.plan.ProjectNode)14 Assignments (io.trino.sql.planner.plan.Assignments)13 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)13 ColumnHandle (io.trino.spi.connector.ColumnHandle)10 PlanNodeIdAllocator (io.trino.sql.planner.PlanNodeIdAllocator)10 AggregationNode (io.trino.sql.planner.plan.AggregationNode)10 CorrelatedJoinNode (io.trino.sql.planner.plan.CorrelatedJoinNode)10 NotExpression (io.trino.sql.tree.NotExpression)10 Map (java.util.Map)10 Type (io.trino.spi.type.Type)9