peng128 commented on code in PR #3057:
URL: https://github.com/apache/calcite/pull/3057#discussion_r1111421995
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -809,14 +810,14 @@ private static String toSql(RelNode root, SqlDialect
dialect,
+ " COUNT(*) AS \"C\"\n"
+ "FROM \"foodmart\".\"product\"\n"
+ "GROUP BY ROLLUP(\"product_class_id\", \"brand_name\")\n"
- + "ORDER BY \"product_class_id\", \"brand_name\", COUNT(*)";
+ + "ORDER BY \"product_class_id\", \"brand_name\", 3";
final String expectedMysql = "SELECT `product_class_id`, `brand_name`,"
+ " COUNT(*) AS `C`\n"
+ "FROM `foodmart`.`product`\n"
+ "GROUP BY `product_class_id`, `brand_name` WITH ROLLUP\n"
+ "ORDER BY `product_class_id` IS NULL, `product_class_id`,"
+ " `brand_name` IS NULL, `brand_name`,"
- + " COUNT(*) IS NULL, COUNT(*)";
+ + " 3 IS NULL, 3";
Review Comment:
I got it. We shouldn't take literal in experssion as field reference.
How about keep original expression when we need to sort null values in order
by?
For example, the output sql will be
```
select "product_class_id", "brand_name", count(*) as c
from "product"
group by rollup("product_class_id", "brand_name")
order by 1, 2, count(*) is null, 3
```
--
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]