ILuffZhe commented on code in PR #4117:
URL: https://github.com/apache/calcite/pull/4117#discussion_r1900836575
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -8620,14 +8620,22 @@ private void checkLiteral2(String expression, String
expected) {
* <a
href="https://issues.apache.org/jira/browse/CALCITE-6748">[CALCITE-6748]
* RelToSqlConverter returns the wrong result when Aggregate is on Sort</a>.
*/
@Test void testAggregateOnSort() {
- final String query = "select max(\"product_class_id\") "
+ final String query0 = "select max(\"product_class_id\") "
+ "from (select * from \"product\" order by \"brand_name\" asc limit
10) t";
- final String expected = "SELECT MAX(\"product_class_id\")\n"
+ final String expected0 = "SELECT MAX(\"product_class_id\")\n"
+ "FROM (SELECT \"product_class_id\"\n"
+ "FROM \"foodmart\".\"product\"\n"
+ "ORDER BY \"brand_name\"\n"
+ "FETCH NEXT 10 ROWS ONLY) AS \"t1\"";
- sql(query).ok(expected);
+ sql(query0).ok(expected0);
+
+ final String query1 = "select max(\"product_class_id\") "
+ + "from (select * from \"product\" offset 10 ) t";
+ final String expected1 = "SELECT MAX(\"product_class_id\")\n"
+ + "FROM (SELECT \"product_class_id\"\n"
+ + "FROM \"foodmart\".\"product\"\n"
+ + "OFFSET 10 ROWS) AS \"t1\"";
Review Comment:
I'm not sure if it's the expected plan as you described in CALCITE-6759. The
result of `COUNT` seems ok if there is no `order by`, do you try
`MAX(\"product_class_id\")` when `order by product_class_id asc`? If the later
loses `order by`, I think there might be some problem.
--
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]