github-actions[bot] commented on code in PR #63379:
URL: https://github.com/apache/doris/pull/63379#discussion_r3456820984
##########
fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java:
##########
@@ -238,6 +242,32 @@ public void accept(NereidsPlanner planner) {
});
}
+ @Test
+ public void testPartitionTopNPrunesPartitionKeyFromSortInfo() throws
Exception {
+ connectContext.getSessionVariable().setEnablePartitionTopN(true);
+ String sql = "select * from (select a, b, rank() over(partition by a
order by a, b) as rk "
+ + "from test_db.t) t where rk <= 1";
+ Planner planner = getSQLPlanner(sql);
+ Assertions.assertNotNull(planner);
+
+ List<PartitionSortNode> partitionSortNodes = new ArrayList<>();
+ for (PlanFragment fragment : planner.getFragments()) {
+ PlanNode root = fragment.getPlanRoot();
+ if (root != null) {
+ root.collect(PartitionSortNode.class, partitionSortNodes);
+ }
+ }
+ Assertions.assertFalse(partitionSortNodes.isEmpty());
+
+ Field sortInfoField = PartitionSortNode.class.getDeclaredField("info");
+ sortInfoField.setAccessible(true);
+ SortInfo sortInfo = (SortInfo)
sortInfoField.get(partitionSortNodes.get(0));
+ List<Expr> orderingExprs = sortInfo.getOrderingExprs();
+ Assertions.assertEquals(1, orderingExprs.size());
Review Comment:
This assertion can false-pass because `orderExprSql` is rendered with
`ToSqlParams.WITH_TABLE`. For this test the table is `test_db.t`, so even the
wrong remaining sort key `test_db.t.a` contains `"b"`, and the test would still
pass after regressing the pruning behavior it is meant to protect. Please
assert the slot identity instead, for example by checking the expression is a
`SlotRef` and comparing `getColumnName()`/`getLabel()` exactly to `"b"` (and
optionally that it is not `"a"`).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]