hsyuan commented on a change in pull request #1606: [CALCITE-3466] Do not drop
the "group by" clause of subquery in a select statement with "group by" clause
in JDBC adapter.
URL: https://github.com/apache/calcite/pull/1606#discussion_r350955938
##########
File path:
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
##########
@@ -321,6 +321,20 @@ private static String toSql(RelNode root, SqlDialect
dialect) {
.ok(expectedMySql);
}
+ @Test public void testSelectQueryWithGroupBySubQuery() {
+ String query = "select \"product_class_id\", count(\"product_id\")\n"
+ + "from (select \"product_class_id\", \"product_id\"\n"
+ + "from \"product\"\n"
+ + "group by \"product_class_id\", \"product_id\") as t\n"
+ + "group by \"product_class_id\"";
+ final String expected = "SELECT \"product_class_id\", COUNT(*)\n"
Review comment:
This is incorrect. `COUNT(*)` doesn't equal with `count("product_id")`, if
product_id is nullable.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services