libenchao commented on code in PR #3085:
URL: https://github.com/apache/calcite/pull/3085#discussion_r1181247359


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -1791,6 +1791,14 @@ private boolean needNewSubQuery(
         return false;
       }
       final Clause maxClause = Collections.max(clauses);
+
+      if (rel instanceof Project
+          && clauses.contains(Clause.ORDER_BY)
+          && dialect.getConformance().isSortByOrdinal()) {
+        // Cannot merge a Project that contains sort by ordinal under it.
+        return hasSortByOrdinal();

Review Comment:
   To be honest, I felt uneasy about moving this up. I'm not sure if we will 
miss some opportunity to add a new sub query. The changes in 
https://github.com/apache/calcite/pull/3057 was also merged by me, and now I 
think that is not perfect as well, since it also suffers from this.
   
   For `needNewSubQuery`, we should only bail out when we returns `true`. In 
that way, we could safely add new conditions into this method, and all the 
cases are orthogonal.



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

Reply via email to