You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "libenchao (via GitHub)" <gi...@apache.org> on 2023/04/30 15:13:47 UTC

[GitHub] [calcite] libenchao commented on a diff in pull request #3085: [CALCITE-5530] RelToSqlConverter[ORDER BY] generates an incorrect fie…

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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org