@Override public PlanNode visitSort(SortNode node, RewriteContext<Set<Symbol>> context) { Set<Symbol> expectedInputs = ImmutableSet.copyOf(concat(context.get(), node.getOrderBy())); PlanNode source = context.rewrite(node.getSource(), expectedInputs); return new SortNode(node.getId(), source, node.getOrderBy(), node.getOrderings()); }
@Override public Void visitSort(SortNode node, Void context) { printNode( node, format("Sort[%s]", Joiner.on(", ").join(node.getOrderBy())), NODE_COLORS.get(NodeType.SORT)); return node.getSource().accept(this, context); }
@Override public ActualProperties visitSort(SortNode node, List<ActualProperties> inputProperties) { ActualProperties properties = Iterables.getOnlyElement(inputProperties); List<SortingProperty<Symbol>> localProperties = node.getOrderBy() .stream() .map(column -> new SortingProperty<>(column, node.getOrderings().get(column))) .collect(toImmutableList()); return ActualProperties.builderFrom(properties).local(localProperties).build(); }
@Override public SubPlanBuilder visitSort(SortNode node, Void context) { SubPlanBuilder current = node.getSource().accept(this, context); if (current.isDistributed()) { current.setRoot( new SinkNode( idAllocator.getNextId(), current.getRoot(), current.getRoot().getOutputSymbols())); // create a new non-partitioned fragment current = createSingleNodePlan( new ExchangeNode( idAllocator.getNextId(), current.getId(), current.getRoot().getOutputSymbols())) .addChild(current.build()); } current.setRoot( new SortNode(node.getId(), current.getRoot(), node.getOrderBy(), node.getOrderings())); return current; }