@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()); }
@Override public PlanWithProperties visitTableWriter(TableWriterNode node, Context context) { PlanWithProperties source = node.getSource().accept(this, context); Optional<PartitionFunctionBinding> partitionFunction = node.getPartitionFunction(); if (!partitionFunction.isPresent() && redistributeWrites) { partitionFunction = Optional.of(new PartitionFunctionBinding(FIXED_RANDOM_DISTRIBUTION, source.getNode().getOutputSymbols(), ImmutableList.of())); } if (partitionFunction.isPresent()) { source = withDerivedProperties( partitionedExchange( idAllocator.getNextId(), source.getNode(), partitionFunction.get()), source.getProperties() ); } return rebaseAndDeriveProperties(node, source); }
@Override public PlanNode visitTableWriter(TableWriterNode node, List<PlanNode> newChildren) { return new TableWriterNode( node.getId(), Iterables.getOnlyElement(newChildren), node.getTarget(), node.getColumns(), node.getColumnNames(), node.getOutputSymbols(), node.getSampleWeightSymbol(), node.getPartitionFunction()); }
@Override public PlanNode visitTableWriter(TableWriterNode node, RewriteContext<Void> context) { PlanNode source = context.rewrite(node.getSource()); // Intentionally does not use canonicalizeAndDistinct as that would remove columns ImmutableList<Symbol> columns = node.getColumns().stream() .map(this::canonicalize) .collect(toImmutableList()); return new TableWriterNode( node.getId(), source, node.getTarget(), columns, node.getColumnNames(), node.getOutputSymbols(), canonicalize(node.getSampleWeightSymbol()), node.getPartitionFunction().map(this::canonicalizePartitionFunctionBinding)); }
newSymbols.build(), node.getSampleWeightSymbol(), node.getPartitionFunction()));
@Override public PlanNode visitTableWriter(TableWriterNode node, RewriteContext<Context> context) { // Part of the plan should be an Optional<StateChangeListener<QueryState>> and this // callback can create the table and abort the table creation if the query fails. TableWriterNode.WriterTarget writerTarget = context.get().getMaterializedHandle(node.getTarget()).get(); return new TableWriterNode( node.getId(), node.getSource().accept(this, context), writerTarget, node.getColumns(), node.getColumnNames(), node.getOutputSymbols(), node.getSampleWeightSymbol(), node.getPartitionFunction()); }