presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/RemoveRedundantSort.java/RemoveRedundantSort/apply
class RemoveRedundantSort:    @Override
    public Result apply(SortNode node, Captures captures, Context context)
    {
        if (isAtMost(node.getSource(), context.getLookup(), 0)) {
            return Result.ofPlanNode(new ValuesNode(node.getId(), node.getOutputSymbols(), ImmutableList.of()));
        }
        if (isScalar(node.getSource(), context.getLookup())) {
            return Result.ofPlanNode(node.getSource());
        }
        return Result.empty();
    }