peng128 commented on code in PR #3057:
URL: https://github.com/apache/calcite/pull/3057#discussion_r1111243681
##########
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 think it valid here.
I try to make a test to compare the relNode compare '3 is null' sql with the
original SQL and the 'count(*) is null' sql.
Using default SqlParser config.
1. For original sql:
```
select "product_class_id", "brand_name",count(*) as c
from "product"
group by rollup("product_class_id", "brand_name")
order by 1, 2, 3
```
relNode is
```
LogicalSort(sort0=[$0], sort1=[$1], sort2=[$2], dir0=[ASC], dir1=[ASC],
dir2=[ASC])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], C=[COUNT()])
LogicalProject(product_class_id=[$0], brand_name=[$2])
JdbcTableScan(table=[[foodmart, product]])
```
2. For 'count(*) is null' sql:
```
select "product_class_id", "brand_name", count(*) as c
from "product"
group by rollup("product_class_id", "brand_name")
order by "product_class_id", "brand_name", count(*) is null, count(*)
```
relNode is
```
LogicalProject(product_class_id=[$0], brand_name=[$1], C=[$2])
LogicalSort(sort0=[$0], sort1=[$1], sort2=[$3], sort3=[$2], dir0=[ASC],
dir1=[ASC], dir2=[ASC], dir3=[ASC])
LogicalProject(product_class_id=[$0], brand_name=[$1], C=[$2],
EXPR$3=[false])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]],
C=[COUNT()])
LogicalProject(product_class_id=[$0], brand_name=[$2])
JdbcTableScan(table=[[foodmart, product]])
```
3. For '3 is null' sql:
```
select "product_class_id", "brand_name", count(*) as c
from "product"
group by rollup("product_class_id", "brand_name")
order by 1, 2, 3 is null, 3
```
relNode is
```
LogicalProject(product_class_id=[$0], brand_name=[$1], C=[$2])
LogicalSort(sort0=[$0], sort1=[$1], sort2=[$3], sort3=[$2], dir0=[ASC],
dir1=[ASC], dir2=[ASC], dir3=[ASC])
LogicalProject(product_class_id=[$0], brand_name=[$1], C=[$2],
EXPR$3=[false])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]],
C=[COUNT()])
LogicalProject(product_class_id=[$0], brand_name=[$2])
JdbcTableScan(table=[[foodmart, product]])
```
The relNode of '3 is null' sql and 'count(*) is null' sql is almost some. Is
my understanding correct?
So I think it's fine here. And I test '3 is null' sql in MySQL, it works.
--
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]