liyafan82 commented on a change in pull request #1907: [CALCITE-3909] 
RelMdMinRowCount doesn't take into account UNION DISTINCT
URL: https://github.com/apache/calcite/pull/1907#discussion_r407300852
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/rel/metadata/RelMdMinRowCount.java
 ##########
 @@ -61,7 +61,12 @@ public Double getMinRowCount(Union rel, RelMetadataQuery 
mq) {
         rowCount += partialRowCount;
       }
     }
-    return rowCount;
+
+    if (rel.all) {
+      return rowCount;
+    } else {
+      return Math.min(rowCount, 1d);
+    }
 
 Review comment:
   Maybe there is a potential improvement here: if rel.all == false, and once 
we find the current value of rowCount greater than 1d, we can stop the loop 
early and directly return 1d.
   
   It also makes the code less readable, so I am not sure if it is worth it. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to