danny0405 commented on a change in pull request #1715: [CALCITE-3662] Generate 
wrong SQL when plan contains Project(Sort(Aggregate)) and aggregate field has 
no alias
URL: https://github.com/apache/calcite/pull/1715#discussion_r364115815
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
 ##########
 @@ -227,8 +227,13 @@ public Result visit(Project e) {
     if (isStar(e.getChildExps(), e.getInput().getRowType(), e.getRowType())) {
       return x;
     }
-    final Builder builder =
-        x.builder(e, Clause.SELECT);
+    final Builder builder;
+    if (e.getInput() instanceof Sort) {
+      builder = x.builder(e);
+      builder.clauses.add(Clause.SELECT);
+    } else {
 
 Review comment:
   We may need to replace the `order by ordinal` with `order by alias` to solve 
this problem completely. Not all the DBs supports order by ordinal, they all 
support order by alias.

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

Reply via email to