gparai commented on a change in pull request #1744: Drill 7148 - Join order, 
multi-col ndv and aggregate rowcount fixes for TPCH queries
URL: https://github.com/apache/drill/pull/1744#discussion_r275195176
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdDistinctRowCount.java
 ##########
 @@ -148,29 +154,59 @@ private Double getDistinctRowCount(DrillScanRelBase 
scan, RelMetadataQuery mq, D
       // Statistics cannot be obtained, use default behaviour
       return scan.estimateRowCount(mq) * 0.1;
     }
-    double s = 1.0;
 
-    for (int i = 0; i < groupKey.length(); i++) {
-      final String colName = type.getFieldNames().get(i);
-      // Skip NDV, if not available
-      if (!groupKey.get(i)) {
-        continue;
+    double s = 1.0;
+    if (((int)PrelUtil.getPlannerSettings(
+        scan.getCluster().getPlanner()).getStatisticsJoinCardinalityMode() & 
2) == 2) {
+      for (int i = 0; i < groupKey.length(); i++) {
+        final String colName = type.getFieldNames().get(i);
+        // Skip NDV, if not available
+        if (!groupKey.get(i)) {
+          continue;
+        }
+        ColumnStatistics columnStatistics = tableMetadata != null ? 
tableMetadata.getColumnStatistics(SchemaPath.getSimplePath(colName)) : null;
+        Double ndv = columnStatistics != null ? (Double) 
columnStatistics.getStatistic(ColumnStatisticsKind.NVD) : null;
 
 Review comment:
   Done

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