You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2019/12/12 04:49:10 UTC

[GitHub] [hive] vineetgarg02 commented on a change in pull request #860: HIVE-22408 The fix for CALCITE-2991 creates wrong results on edge case

vineetgarg02 commented on a change in pull request #860: HIVE-22408 The fix for CALCITE-2991 creates wrong results on edge case
URL: https://github.com/apache/hive/pull/860#discussion_r356957099
 
 

 ##########
 File path: ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveSortLimitRemoveRule.java
 ##########
 @@ -41,8 +42,17 @@ public boolean matches(RelOptRuleCall call) {
     final HiveSortLimit sortLimit = call.rel(0);
 
     Double maxRowCount = call.getMetadataQuery().getMaxRowCount(sortLimit.getInput());
-    if (maxRowCount != null &&(maxRowCount <= 1)) {
-      return true;
+    if (maxRowCount != null) {
+      if (sortLimit.getFetchExpr() != null) {
+        // we have LIMIT
+        int limit = RexLiteral.intValue(sortLimit.getFetchExpr());
+        if (maxRowCount <= limit) {
 
 Review comment:
   @kgyrtkirk `MaxRowCount` is guaranteed to return the number of rows which will be >= the actual number of rows, therefore we should never end up removing LIMIT when we shoudn't

----------------------------------------------------------------
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: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org