amansinha100 commented on a change in pull request #1699: DRILL-7108: Improve 
selectivity estimates for (NOT)LIKE, NOT_EQUALS, IS NOT NULL predicates
URL: https://github.com/apache/drill/pull/1699#discussion_r266491303
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillStatsTable.java
 ##########
 @@ -134,6 +135,33 @@ public Double getRowCount() {
     return rowCount > 0 ? rowCount : null;
   }
 
+  /**
+   * Get the approximate number of distinct values of given column. If stats 
are not present for the
+   * given column, a null is returned.
+   *
+   * Note: returned data may not be accurate. Accuracy depends on whether the 
table data has changed
+   * after the stats are computed.
+   *
+   * @param col - column for which approximate count distinct is desired
+   * @return approximate count distinct of the column, if available. NULL 
otherwise.
+   */
+  public Double getNNRowCount(String col) {
+    // Stats might not have materialized because of errors.
+    if (!materialized) {
+      return null;
+    }
+    final String upperCol = col.toUpperCase();
+    Long nnRowCntCol = nnRowCount.get(upperCol);
+    if (nnRowCntCol == null) {
+      nnRowCntCol = 
nnRowCount.get(SchemaPath.getSimplePath(upperCol).toString());
+    }
+    // Ndv estimation techniques like HLL may over-estimate, hence cap it at 
rowCount
 
 Review comment:
   Update for NN row count. 

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