liyafan82 commented on a change in pull request #2154:
URL: https://github.com/apache/calcite/pull/2154#discussion_r490725620



##########
File path: 
core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistinctRowCount.java
##########
@@ -79,6 +82,37 @@ public Double getDistinctRowCount(RelNode rel, 
RelMetadataQuery mq,
     return null;
   }
 
+  public Double getDistinctRowCount(TableScan rel, RelMetadataQuery mq,
+      ImmutableBitSet groupKey, RexNode predicate) {
+    final double selectivity = predicate == null ? 1D : mq.getSelectivity(rel, 
predicate);
+    final boolean uniq = RelMdUtil.areColumnsDefinitelyUnique(mq, rel, 
groupKey);
+    if (uniq) {
+      return NumberUtil.multiply(mq.getRowCount(rel), selectivity);

Review comment:
       If the column values are unique, shouldn't we return 1 * selectivity?




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


Reply via email to