Ejemplo n.º 1
0
    @Override
    public PlanNode visitTableWriter(TableWriterNode node, RewriteContext<Set<Symbol>> context) {
      ImmutableSet.Builder<Symbol> expectedInputs =
          ImmutableSet.<Symbol>builder().addAll(node.getColumns());
      if (node.getSampleWeightSymbol().isPresent()) {
        expectedInputs.add(node.getSampleWeightSymbol().get());
      }
      if (node.getPartitionFunction().isPresent()) {
        PartitionFunctionBinding functionBinding = node.getPartitionFunction().get();
        functionBinding
            .getPartitionFunctionArguments()
            .stream()
            .filter(PartitionFunctionArgumentBinding::isVariable)
            .map(PartitionFunctionArgumentBinding::getColumn)
            .forEach(expectedInputs::add);
        functionBinding.getHashColumn().ifPresent(expectedInputs::add);
      }
      PlanNode source = context.rewrite(node.getSource(), expectedInputs.build());

      return new TableWriterNode(
          node.getId(),
          source,
          node.getTarget(),
          node.getColumns(),
          node.getColumnNames(),
          node.getOutputSymbols(),
          node.getSampleWeightSymbol(),
          node.getPartitionFunction());
    }