Esempio n. 1
0
    @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 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);
    }