You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by gp...@apache.org on 2019/03/22 23:53:31 UTC
[drill] branch master updated: DRILL-7109: Apply selectivity
calculations to single column filter predicates
This is an automated email from the ASF dual-hosted git repository.
gparai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git
The following commit(s) were added to refs/heads/master by this push:
new 212e5c0 DRILL-7109: Apply selectivity calculations to single column filter predicates
212e5c0 is described below
commit 212e5c0d9656cd572426aa514bf37e0bd002bdd6
Author: Gautam Parai <gp...@maprtech.com>
AuthorDate: Mon Mar 18 12:55:07 2019 -0700
DRILL-7109: Apply selectivity calculations to single column filter predicates
closes #1701
---
.../exec/planner/cost/DrillRelMdSelectivity.java | 23 ++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdSelectivity.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdSelectivity.java
index e87fae2..ec72822 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdSelectivity.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdSelectivity.java
@@ -144,7 +144,9 @@ public class DrillRelMdSelectivity extends RelMdSelectivity {
for (RexNode pred : RelOptUtil.conjunctions(predicate)) {
double orSel = 0;
for (RexNode orPred : RelOptUtil.disjunctions(pred)) {
- if (orPred.isA(SqlKind.EQUALS)) {
+ if (isMultiColumnPredicate(orPred)) {
+ orSel += RelMdUtil.guessSelectivity(orPred); //CALCITE guess
+ } else if (orPred.isA(SqlKind.EQUALS)) {
orSel += computeEqualsSelectivity(table, orPred, fieldNames);
} else if (orPred.isA(SqlKind.NOT_EQUALS)) {
orSel += 1.0 - computeEqualsSelectivity(table, orPred, fieldNames);
@@ -286,7 +288,7 @@ public class DrillRelMdSelectivity extends RelMdSelectivity {
return sel;
}
- public static RexInputRef findRexInputRef(final RexNode node) {
+ private static RexInputRef findRexInputRef(final RexNode node) {
try {
RexVisitor<Void> visitor =
new RexVisitorImpl<Void>(true) {
@@ -308,4 +310,21 @@ public class DrillRelMdSelectivity extends RelMdSelectivity {
return (RexInputRef) e.getNode();
}
}
+
+ private boolean isMultiColumnPredicate(final RexNode node) {
+ return findAllRexInputRefs(node).size() > 1;
+ }
+
+ private static List<RexInputRef> findAllRexInputRefs(final RexNode node) {
+ List<RexInputRef> rexRefs = new ArrayList<>();
+ RexVisitor<Void> visitor =
+ new RexVisitorImpl<Void>(true) {
+ public Void visitInputRef(RexInputRef inputRef) {
+ rexRefs.add(inputRef);
+ return super.visitInputRef(inputRef);
+ }
+ };
+ node.accept(visitor);
+ return rexRefs;
+ }
}