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 21:02:54 UTC

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

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

 ##########
 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:
   I don't actually think it is .. important to set here, I copied from sort collapse rule just to be safe, but the unit test and my manual test passes without it, so I don't believe it is necessary and have removed this line instead.

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