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_r266510036
##########
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);
Review comment:
For all the selectivity functions, the rest of the code except for the main
formula is the same. Can we factor out the surrounding code (including the
logging etc.) and only have predicate-specific formula in the function ?
----------------------------------------------------------------
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