public PlanNode plan(Analysis analysis)
    {
        return planStatement(analysis, analysis.getStatement());
    }
@Test
    public void testRedundantTopNNodeRemoval()
    {
        Session exploitConstraints = Session.builder(this.getQueryRunner().getDefaultSession())
                .setSystemProperty(EXPLOIT_CONSTRAINTS, Boolean.toString(true))
                .build();

        String query = "SELECT count(*) FROM orders ORDER BY 1 LIMIT 10";
        assertFalse(
                searchFrom(plan(query, OPTIMIZED, exploitConstraints).getRoot())
                        .where(isInstanceOfAny(TopNNode.class, SortNode.class))
                        .matches(),
                format("Unexpected TopN node for query: '%s'", query));

        assertPlan(
                "SELECT orderkey, count(*) FROM orders GROUP BY orderkey ORDER BY 1 LIMIT 10",
                output(
                        node(TopNNode.class,
                                anyTree(
                                        tableScan("orders")))));

        assertPlan(
                "SELECT orderkey, count(*) FROM orders GROUP BY orderkey ORDER BY 1 LIMIT 0",
                output(
                        node(ValuesNode.class)));
    }