morrySnow commented on code in PR #64849:
URL: https://github.com/apache/doris/pull/64849#discussion_r3489313857
##########
fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/EliminateGroupByKeyTest.java:
##########
@@ -181,6 +183,25 @@ void testEliminateByEqual() {
&&
agg.getGroupByExpressions().get(0).toSql().equals("name")));
}
+ @Test
+ void testEliminateByPkWithOutputNeeded() throws Exception {
+ // Regression: when a group-by key (name) is FD-redundant (id -> name)
+ // but still appears in SELECT, it should be removed from group-by
+ // and wrapped with ANY_VALUE in the output.
+ addConstraint("alter table t1 add constraint pk2 primary key (id)");
Review Comment:
The `addConstraint` / `dropConstraint` calls are not wrapped in
`try-finally`. If the assertion fails mid-test, `dropConstraint` is never
called, leaving the PK constraint on `t1` — potentially affecting subsequent
tests (`testEliminateByUniform`, `testEliminateByPk`). Consider wrapping in
`try { addConstraint(...); ... } finally { dropConstraint(...); }`.
--
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]