You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by jn...@apache.org on 2015/05/11 22:53:30 UTC
drill git commit: DRILL-3018: Fix CanNotPlan for nestLoop left join,
caused by row count estimation issue.
Repository: drill
Updated Branches:
refs/heads/master 4689468ef -> a7359f36b
DRILL-3018: Fix CanNotPlan for nestLoop left join, caused by row count estimation issue.
Add unit testcase.
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/a7359f36
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/a7359f36
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/a7359f36
Branch: refs/heads/master
Commit: a7359f36b517e667b7e64a474154fb5b2238e620
Parents: 4689468
Author: Jinfeng Ni <jn...@apache.org>
Authored: Mon May 11 09:02:17 2015 -0700
Committer: Jinfeng Ni <jn...@apache.org>
Committed: Mon May 11 11:05:38 2015 -0700
----------------------------------------------------------------------
.../cost/DrillDefaultRelMetadataProvider.java | 3 +-
.../cost/DrillRelMdDistinctRowCount.java | 5 ---
.../exec/planner/cost/DrillRelMdRowCount.java | 42 ++++++++++++++++++++
.../org/apache/drill/TestExampleQueries.java | 11 +++++
4 files changed, 55 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/a7359f36/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillDefaultRelMetadataProvider.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillDefaultRelMetadataProvider.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillDefaultRelMetadataProvider.java
index 7e60fd0..9096830 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillDefaultRelMetadataProvider.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillDefaultRelMetadataProvider.java
@@ -27,6 +27,7 @@ public class DrillDefaultRelMetadataProvider {
}
public static final RelMetadataProvider INSTANCE = ChainedRelMetadataProvider.of(ImmutableList
- .of(DrillRelMdDistinctRowCount.SOURCE,
+ .of(DrillRelMdRowCount.SOURCE,
+ DrillRelMdDistinctRowCount.SOURCE,
new DefaultRelMetadataProvider()));
}
http://git-wip-us.apache.org/repos/asf/drill/blob/a7359f36/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdDistinctRowCount.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdDistinctRowCount.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdDistinctRowCount.java
index 90d6bb8..77645e7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdDistinctRowCount.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdDistinctRowCount.java
@@ -17,18 +17,13 @@
******************************************************************************/
package org.apache.drill.exec.planner.cost;
-import org.apache.calcite.adapter.enumerable.EnumerableTableScan;
-import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.rel.core.TableScan;
import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
import org.apache.calcite.rel.metadata.RelMdDistinctRowCount;
import org.apache.calcite.rel.metadata.RelMetadataProvider;
-import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.util.BuiltInMethod;
import org.apache.calcite.util.ImmutableBitSet;
-import org.apache.drill.exec.planner.logical.DrillRel;
import org.apache.drill.exec.planner.logical.DrillScanRel;
public class DrillRelMdDistinctRowCount extends RelMdDistinctRowCount{
http://git-wip-us.apache.org/repos/asf/drill/blob/a7359f36/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdRowCount.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdRowCount.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdRowCount.java
new file mode 100644
index 0000000..b3c8834
--- /dev/null
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelMdRowCount.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.apache.drill.exec.planner.cost;
+
+import org.apache.calcite.rel.core.Aggregate;
+import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
+import org.apache.calcite.rel.metadata.RelMdRowCount;
+import org.apache.calcite.rel.metadata.RelMetadataProvider;
+import org.apache.calcite.util.BuiltInMethod;
+import org.apache.calcite.util.ImmutableBitSet;
+
+public class DrillRelMdRowCount extends RelMdRowCount{
+ private static final DrillRelMdRowCount INSTANCE = new DrillRelMdRowCount();
+
+ public static final RelMetadataProvider SOURCE = ReflectiveRelMetadataProvider.reflectiveSource(BuiltInMethod.ROW_COUNT.method, INSTANCE);
+
+ @Override
+ public Double getRowCount(Aggregate rel) {
+ ImmutableBitSet groupKey = ImmutableBitSet.range(rel.getGroupCount());
+
+ if (groupKey.isEmpty()) {
+ return 1.0;
+ } else {
+ return super.getRowCount(rel);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/drill/blob/a7359f36/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
index b75f644..dad43a3 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
@@ -950,4 +950,15 @@ public class TestExampleQueries extends BaseTestQuery{
.build()
.run();
}
+
+ @Test //DRILL-3018
+ public void testNestLoopJoinScalarSubQ() throws Exception {
+ testBuilder()
+ .sqlQuery("select n_nationkey from cp.`tpch/nation.parquet` where n_nationkey >= (select min(c_nationkey) from cp.`tpch/customer.parquet`)")
+ .unOrdered()
+ .sqlBaselineQuery("select n_nationkey from cp.`tpch/nation.parquet`")
+ .build()
+ .run();
+ }
+
}