You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/12/15 19:56:37 UTC

[GitHub] [incubator-druid] jon-wei commented on a change in pull request #9043: sql auto limit wrapping fix

jon-wei commented on a change in pull request #9043: sql auto limit wrapping fix
URL: https://github.com/apache/incubator-druid/pull/9043#discussion_r358001637
 
 

 ##########
 File path: sql/src/main/java/org/apache/druid/sql/calcite/planner/DruidPlanner.java
 ##########
 @@ -258,24 +258,30 @@ private RelNode possiblyWrapRootWithOuterLimitFromContext(
     if (root.rel instanceof Sort) {
       Sort innerSort = (Sort) root.rel;
       final int offset = Calcites.getOffset(innerSort);
+      final int innerLimit = Calcites.getFetch(innerSort);
       final int fetch = Calcites.collapseFetch(
-          Calcites.getFetch(innerSort),
+          innerLimit,
           Ints.checkedCast(outerLimit),
           0
       );
 
+      if (fetch == innerLimit) {
+        // nothing to do, don't bother to make a new sort
+        return root.rel;
+      }
+
+      root.rel.getCluster().getPlanner().setImportance(innerSort, 0.0);
 
 Review comment:
   Can you add comment on what the `setImportance` call does?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org