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/16 17:30:23 UTC

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

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

 ##########
 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:
   Setting the importance of a rel to 0 is a way to tell the planner that it should not waste its time considering that rel: i.e., we are confident the new rel is better.

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