node.getOutputSymbols().size() == node.getGroupBy().size() &&
node.getOutputSymbols().containsAll(node.getGroupBy())) {
checkArgument(!context.getSampleWeight().isPresent(), "sample weight symbol referenced after a DISTINCT node");
checkArgument(!node.getSampleWeight().isPresent(), "DISTINCT aggregation has sample weight symbol");
PlanNode rewrittenSource = planRewriter.rewrite(node.getSource(), null);
return new DistinctLimitNode(idAllocator.getNextId(), rewrittenSource, context.getCount());
}
PlanNode rewrittenNode = planRewriter.defaultRewrite(node, null);
if (context != null) {
checkState(!context.getSampleWeight().isPresent(), "Aggregations do not output a sample weight, but limit consumes one");
// Drop in a LimitNode b/c limits cannot be pushed through aggregations