zzwqqq commented on code in PR #5101:
URL: https://github.com/apache/calcite/pull/5101#discussion_r3592173153


##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -2016,6 +2016,40 @@ private static String toSql(RelNode root, SqlDialect 
dialect,
     relFn(relFn).withOracle().ok(expectedOracle);
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-7655";>[CALCITE-7655]
+   * RelToSqlConverter incorrectly removes a subquery when grouping by a 
window function
+   * result</a>. */
+  @Test void testGroupByWindowFunction() {
+    final String query = "SELECT \"EMPNO\", \"row_number\", COUNT(*) AS 
\"c\"\n"
+        + "FROM (\n"
+        + "  SELECT \"EMPNO\",\n"
+        + "    ROW_NUMBER() OVER (ORDER BY \"EMPNO\" NULLS FIRST) AS 
\"row_number\"\n"
+        + "  FROM \"EMP\") AS \"t\"\n"
+        + "GROUP BY \"EMPNO\", \"row_number\"";
+
+    final String expectedMysql = "SELECT `EMPNO`, `row_number`, COUNT(*) AS 
`c`\n"

Review Comment:
   Yeah, I've verified them:
   https://onecompiler.com/mysql/44vbzf2zh
   https://onecompiler.com/oracle/44vbzehcw
   https://onecompiler.com/postgresql/44vbze2j3



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