@Override public ActualProperties visitUnnest(UnnestNode node, List<ActualProperties> inputProperties) { Set<Symbol> passThroughInputs = ImmutableSet.copyOf(node.getReplicateSymbols()); return Iterables.getOnlyElement(inputProperties).translate(column -> { if (passThroughInputs.contains(column)) { return Optional.of(column); } return Optional.empty(); }); }
@Override public ActualProperties visitUnnest(UnnestNode node, List<ActualProperties> inputProperties) { Set<Symbol> passThroughInputs = ImmutableSet.copyOf(node.getReplicateSymbols()); return Iterables.getOnlyElement(inputProperties).translate(column -> { if (passThroughInputs.contains(column)) { return Optional.of(column); } return Optional.empty(); }); }
@Override public StreamProperties visitUnnest(UnnestNode node, List<StreamProperties> inputProperties) { StreamProperties properties = Iterables.getOnlyElement(inputProperties); // We can describe properties in terms of inputs that are projected unmodified (i.e., not the unnested symbols) Set<Symbol> passThroughInputs = ImmutableSet.copyOf(node.getReplicateSymbols()); return properties.translate(column -> { if (passThroughInputs.contains(column)) { return Optional.of(column); } return Optional.empty(); }); }
@Override public StreamProperties visitUnnest(UnnestNode node, List<StreamProperties> inputProperties) { StreamProperties properties = Iterables.getOnlyElement(inputProperties); // We can describe properties in terms of inputs that are projected unmodified (i.e., not the unnested symbols) Set<Symbol> passThroughInputs = ImmutableSet.copyOf(node.getReplicateSymbols()); return properties.translate(column -> { if (passThroughInputs.contains(column)) { return Optional.of(column); } return Optional.empty(); }); }
@Override public PlanWithProperties visitUnnest(UnnestNode node, PreferredProperties preferredProperties) { PreferredProperties translatedPreferred = preferredProperties.translate(symbol -> node.getReplicateSymbols().contains(symbol) ? Optional.of(symbol) : Optional.empty()); return rebaseAndDeriveProperties(node, planChild(node, translatedPreferred)); }
@Override public PlanWithProperties visitUnnest(UnnestNode node, PreferredProperties preferredProperties) { PreferredProperties translatedPreferred = preferredProperties.translate(symbol -> node.getReplicateSymbols().contains(symbol) ? Optional.of(symbol) : Optional.empty()); return rebaseAndDeriveProperties(node, planChild(node, translatedPreferred)); }
@Override public Void visitUnnest(UnnestNode node, Set<Symbol> boundSymbols) { PlanNode source = node.getSource(); source.accept(this, boundSymbols); Set<Symbol> required = ImmutableSet.<Symbol>builder() .addAll(node.getReplicateSymbols()) .addAll(node.getUnnestSymbols().keySet()) .build(); checkDependencies(source.getOutputSymbols(), required, "Invalid node. Dependencies (%s) not in source plan output (%s)", required, source.getOutputSymbols()); return null; }
@Override public Void visitUnnest(UnnestNode node, Set<Symbol> boundSymbols) { PlanNode source = node.getSource(); source.accept(this, boundSymbols); Set<Symbol> required = ImmutableSet.<Symbol>builder() .addAll(node.getReplicateSymbols()) .addAll(node.getUnnestSymbols().keySet()) .build(); checkDependencies(source.getOutputSymbols(), required, "Invalid node. Dependencies (%s) not in source plan output (%s)", required, source.getOutputSymbols()); return null; }
@Override public PlanNode visitUnnest(UnnestNode node, RewriteContext<Void> context) { PlanNode source = context.rewrite(node.getSource()); ImmutableMap.Builder<Symbol, List<Symbol>> builder = ImmutableMap.builder(); for (Map.Entry<Symbol, List<Symbol>> entry : node.getUnnestSymbols().entrySet()) { builder.put(canonicalize(entry.getKey()), entry.getValue()); } return new UnnestNode(node.getId(), source, canonicalizeAndDistinct(node.getReplicateSymbols()), builder.build(), node.getOrdinalitySymbol()); }
@Override public PlanNode visitUnnest(UnnestNode node, RewriteContext<Set<Symbol>> context) { List<Symbol> replicateSymbols = node.getReplicateSymbols().stream() .filter(context.get()::contains) .collect(toImmutableList()); Optional<Symbol> ordinalitySymbol = node.getOrdinalitySymbol(); if (ordinalitySymbol.isPresent() && !context.get().contains(ordinalitySymbol.get())) { ordinalitySymbol = Optional.empty(); } Map<Symbol, List<Symbol>> unnestSymbols = node.getUnnestSymbols(); ImmutableSet.Builder<Symbol> expectedInputs = ImmutableSet.<Symbol>builder() .addAll(replicateSymbols) .addAll(unnestSymbols.keySet()); PlanNode source = context.rewrite(node.getSource(), expectedInputs.build()); return new UnnestNode(node.getId(), source, replicateSymbols, unnestSymbols, ordinalitySymbol); }
@Override public PlanNode visitUnnest(UnnestNode node, RewriteContext<Set<Symbol>> context) { List<Symbol> replicateSymbols = node.getReplicateSymbols().stream() .filter(context.get()::contains) .collect(toImmutableList()); Optional<Symbol> ordinalitySymbol = node.getOrdinalitySymbol(); if (ordinalitySymbol.isPresent() && !context.get().contains(ordinalitySymbol.get())) { ordinalitySymbol = Optional.empty(); } Map<Symbol, List<Symbol>> unnestSymbols = node.getUnnestSymbols(); ImmutableSet.Builder<Symbol> expectedInputs = ImmutableSet.<Symbol>builder() .addAll(replicateSymbols) .addAll(unnestSymbols.keySet()); PlanNode source = context.rewrite(node.getSource(), expectedInputs.build()); return new UnnestNode(node.getId(), source, replicateSymbols, unnestSymbols, ordinalitySymbol); }
@Override public PlanNode visitUnnest(UnnestNode node, RewriteContext<Void> context) { PlanNode source = context.rewrite(node.getSource()); ImmutableMap.Builder<Symbol, List<Symbol>> builder = ImmutableMap.builder(); for (Map.Entry<Symbol, List<Symbol>> entry : node.getUnnestSymbols().entrySet()) { builder.put(canonicalize(entry.getKey()), entry.getValue()); } return new UnnestNode(node.getId(), source, canonicalizeAndDistinct(node.getReplicateSymbols()), builder.build(), node.getOrdinalitySymbol()); }
for (Symbol symbol : node.getReplicateSymbols()) { replicateTypes.add(context.getTypes().get(symbol)); ordinalityType.ifPresent(type -> checkState(type.equals(BIGINT), "Type of ordinalitySymbol must always be BIGINT.")); List<Integer> replicateChannels = getChannelsForSymbols(node.getReplicateSymbols(), source.getLayout()); List<Integer> unnestChannels = getChannelsForSymbols(unnestSymbols, source.getLayout()); for (Symbol symbol : node.getReplicateSymbols()) { outputMappings.put(symbol, channel); channel++;
for (Symbol symbol : node.getReplicateSymbols()) { replicateTypes.add(context.getTypes().get(symbol)); ordinalityType.ifPresent(type -> checkState(type.equals(BIGINT), "Type of ordinalitySymbol must always be BIGINT.")); List<Integer> replicateChannels = getChannelsForSymbols(node.getReplicateSymbols(), source.getLayout()); List<Integer> unnestChannels = getChannelsForSymbols(unnestSymbols, source.getLayout()); for (Symbol symbol : node.getReplicateSymbols()) { outputMappings.put(symbol, channel); channel++;
@Override public PlanWithProperties visitUnnest(UnnestNode node, HashComputationSet parentPreference) { PlanWithProperties child = plan(node.getSource(), parentPreference.pruneSymbols(node.getSource().getOutputSymbols())); // only pass through hash symbols requested by the parent Map<HashComputation, Symbol> hashSymbols = new HashMap<>(child.getHashSymbols()); hashSymbols.keySet().retainAll(parentPreference.getHashes()); return new PlanWithProperties( new UnnestNode( node.getId(), child.getNode(), ImmutableList.<Symbol>builder() .addAll(node.getReplicateSymbols()) .addAll(hashSymbols.values()) .build(), node.getUnnestSymbols(), node.getOrdinalitySymbol()), hashSymbols); }
@Override public PlanWithProperties visitUnnest(UnnestNode node, HashComputationSet parentPreference) { PlanWithProperties child = plan(node.getSource(), parentPreference.pruneSymbols(node.getSource().getOutputSymbols())); // only pass through hash symbols requested by the parent Map<HashComputation, Symbol> hashSymbols = new HashMap<>(child.getHashSymbols()); hashSymbols.keySet().retainAll(parentPreference.getHashes()); return new PlanWithProperties( new UnnestNode( node.getId(), child.getNode(), ImmutableList.<Symbol>builder() .addAll(node.getReplicateSymbols()) .addAll(hashSymbols.values()) .build(), node.getUnnestSymbols(), node.getOrdinalitySymbol()), hashSymbols); }
Expression rewrittenConjunct = equalityInference.rewriteExpression(conjunct, in(node.getReplicateSymbols())); if (rewrittenConjunct != null) { pushdownConjuncts.add(rewrittenConjunct); EqualityInference.EqualityPartition equalityPartition = equalityInference.generateEqualitiesPartitionedBy(in(node.getReplicateSymbols())::apply); pushdownConjuncts.addAll(equalityPartition.getScopeEqualities()); postUnnestConjuncts.addAll(equalityPartition.getScopeComplementEqualities()); output = new UnnestNode(node.getId(), rewrittenSource, node.getReplicateSymbols(), node.getUnnestSymbols(), node.getOrdinalitySymbol());
Expression rewrittenConjunct = equalityInference.rewriteExpression(conjunct, in(node.getReplicateSymbols())); if (rewrittenConjunct != null) { pushdownConjuncts.add(rewrittenConjunct); EqualityInference.EqualityPartition equalityPartition = equalityInference.generateEqualitiesPartitionedBy(in(node.getReplicateSymbols())::apply); pushdownConjuncts.addAll(equalityPartition.getScopeEqualities()); postUnnestConjuncts.addAll(equalityPartition.getScopeComplementEqualities()); output = new UnnestNode(node.getId(), rewrittenSource, node.getReplicateSymbols(), node.getUnnestSymbols(), node.getOrdinalitySymbol());
@Override public Void visitUnnest(UnnestNode node, Integer indent) { print(indent, "- Unnest [replicate=%s, unnest=%s] => [%s]", formatOutputs(node.getReplicateSymbols()), formatOutputs(node.getUnnestSymbols().keySet()), formatOutputs(node.getOutputSymbols())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); return processChildren(node, indent + 1); }
@Override public Void visitUnnest(UnnestNode node, Integer indent) { print(indent, "- Unnest [replicate=%s, unnest=%s] => [%s]", formatOutputs(node.getReplicateSymbols()), formatOutputs(node.getUnnestSymbols().keySet()), formatOutputs(node.getOutputSymbols())); printPlanNodesStatsAndCost(indent + 2, node); printStats(indent + 2, node.getId()); return processChildren(node, indent + 1); }