gparai 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_r267136173
########## File path: exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdSelectivity.java ########## @@ -173,6 +173,61 @@ private double getScanSelectivityInternal(DrillTable table, RexNode predicate, L return (sel > 1.0) ? 1.0 : sel; } + private double computeEqualsSelectivity(DrillTable table, RexNode orPred, List<String> fieldNames) { + if (orPred instanceof RexCall) { + int colIdx = -1; + RexInputRef op = findRexInputRef(orPred); + if (op != null) { + colIdx = op.hashCode(); + } + if (colIdx != -1 && colIdx < fieldNames.size()) { + String col = fieldNames.get(colIdx); + if (table.getStatsTable() != null + && table.getStatsTable().getNdv(col) != null) { + return 1.00 / table.getStatsTable().getNdv(col); + } + } else { + if (logger.isDebugEnabled()) { + logger.warn(String.format("No input reference $[%s] found for predicate [%s]", + Integer.toString(colIdx), orPred.toString())); + } + } + } + if (logger.isDebugEnabled()) { + logger.warn(String.format("Using guess for predicate [%s]", orPred.toString())); + } + //CALCITE guess + return RelMdUtil.guessSelectivity(orPred); + } + + private double computeNullSelectivity(DrillTable table, RexNode orPred, List<String> fieldNames) { 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: us...@infra.apache.org With regards, Apache Git Services