vlsi commented on code in PR #5225:
URL: https://github.com/apache/calcite/pull/5225#discussion_r4363868933


##########
core/src/main/java/org/apache/calcite/sql/validate/OrderByScope.java:
##########
@@ -93,6 +96,27 @@ public class OrderByScope extends DelegatingScope {
 
   @Override public void validateExpr(SqlNode expr) {
     SqlNode expanded = validator.expandOrderExpr(select, expr);
+    expanded.accept(
+        new AggVisitor(validator.getOperatorTable(), false, true,
+            false, null, validator.catalogReader.nameMatcher()) {
+          @Override public Void visit(SqlCall call) {
+            switch (call.getKind()) {
+            case FILTER:
+            case WITHIN_GROUP:

Review Comment:
   Removing the `WITHIN_GROUP` and `WITHIN_DISTINCT` cases leaves 
`SqlValidatorTest` and `JdbcTest` green, yet `select max(sal) as m, deptno from 
emp group by deptno order by sum(sal) within distinct (m)` then passes 
validation again. `WITHIN_GROUP` is already reported by `AggVisitor.visit` 
itself when `aggregate` is true, so that case changes nothing. Please drop 
`case WITHIN_GROUP` and add the `WITHIN DISTINCT` query above to 
`SqlValidatorTest` as a failing case.



-- 
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]

Reply via email to