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_r266503722
 
 

 ##########
 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());
 
 Review comment:
   Could you remind me why we have to try a second time with a different key ?  
The nnRowCount hash map is only populated at line 185 which uses the 
col.toUpperCase() as the key.  If at all we need a second key, shouldn't that 
also be stored in the hash map ?

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