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



##########
File path: core/src/main/java/org/apache/calcite/util/RangeSets.java
##########
@@ -105,6 +110,45 @@ private RangeSets() {}
     return 0;
   }
 
+  /**
+   * Estimates the number of distinct values for a range (if possible).
+   * A null is returned if the number of distinct values is infinity or 
unknown.
+   */
+  public static <C extends Comparable<C>> @Nullable Double numDistinctVals(
+      Range<C> range, RelDataType type) {
+    if (RangeSets.isPoint(range)) {
+      return 1.0;

Review comment:
       Returning null means we do not have an estimation, or equivalently, the 
number of distinct values is infinity.
   
   When the range is a point (e.g. `x = 1`), we estimate that there is only one 
distinct value, which is likely to be true in practice. 




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