924060929 commented on code in PR #31227: URL: https://github.com/apache/doris/pull/31227#discussion_r1498779247
########## fe/fe-core/src/test/java/org/apache/doris/nereids/jobs/joinorder/TPCHTest.java: ########## @@ -33,4 +38,34 @@ void testQ5() { .dpHypOptimize() .printlnBestPlanTree(); } + + + // count(*) projects on children key columns + @Test + void testCountStarProject() { + String sql = "select\n" + + " count(*) as order_count\n" + + "from\n" + + " orders\n" + + "where\n" + + " o_orderdate >= date '1993-07-01'\n" + + " and o_orderdate < date '1993-07-01' + interval '3' month\n" + + " and exists (\n" + + " select\n" + + " *\n" + + " from\n" + + " lineitem\n" + + " where\n" + + " l_orderkey = o_orderkey\n" + + " and l_commitdate < l_receiptdate\n" + + " );"; + + PlanChecker checker = PlanChecker.from(connectContext) + .analyze(sql) + .rewrite(); + List<? extends Expression> proj = checker.getPlan().child(0).child(0).getExpressions(); + Assertions.assertEquals(proj.size(), 1); + Assertions.assertTrue(proj.get(0) instanceof SlotReference + && "o_orderdate".equals(proj.get(0).toSql())); Review Comment: please check the shape of top plan, is it `logicalResultSink(logicalAggregate(logicalProject()))`? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org