You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2014/07/09 01:10:41 UTC

git commit: [OPTIQ-313] Query decorrelation fails

Repository: incubator-optiq
Updated Branches:
  refs/heads/master c54a56844 -> 58ddf6bff


[OPTIQ-313] Query decorrelation fails


Project: http://git-wip-us.apache.org/repos/asf/incubator-optiq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-optiq/commit/58ddf6bf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-optiq/tree/58ddf6bf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-optiq/diff/58ddf6bf

Branch: refs/heads/master
Commit: 58ddf6bff360948618743359eb29201bc36428a5
Parents: c54a568
Author: Julian Hyde <jh...@apache.org>
Authored: Mon Jul 7 18:07:22 2014 -0700
Committer: Julian Hyde <ju...@gmail.com>
Committed: Tue Jul 8 15:59:26 2014 -0700

----------------------------------------------------------------------
 .../org/eigenbase/sql2rel/RelDecorrelator.java  |  4 +---
 .../net/hydromatic/optiq/test/JdbcTest.java     | 23 ++++++++++++++++++++
 .../optiq/test/MaterializationTest.java         | 13 -----------
 .../net/hydromatic/optiq/test/OptiqAssert.java  |  3 ++-
 .../hydromatic/optiq/impl/tpch/TpchTest.java    |  3 +--
 5 files changed, 27 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/58ddf6bf/core/src/main/java/org/eigenbase/sql2rel/RelDecorrelator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eigenbase/sql2rel/RelDecorrelator.java b/core/src/main/java/org/eigenbase/sql2rel/RelDecorrelator.java
index e20a9d1..e21cb0d 100644
--- a/core/src/main/java/org/eigenbase/sql2rel/RelDecorrelator.java
+++ b/core/src/main/java/org/eigenbase/sql2rel/RelDecorrelator.java
@@ -24,7 +24,6 @@ import java.util.logging.*;
 import org.eigenbase.rel.*;
 import org.eigenbase.rel.CorrelatorRel.Correlation;
 import org.eigenbase.rel.metadata.*;
-import org.eigenbase.rel.rules.PushFilterPastJoinRule;
 import org.eigenbase.relopt.*;
 import org.eigenbase.relopt.hep.*;
 import org.eigenbase.reltype.*;
@@ -184,7 +183,6 @@ public class RelDecorrelator implements ReflectiveVisitor {
         .addRuleInstance(new RemoveSingleAggregateRule())
         .addRuleInstance(new RemoveCorrelationForScalarProjectRule())
         .addRuleInstance(new RemoveCorrelationForScalarAggregateRule())
-        .addRuleInstance(PushFilterPastJoinRule.FILTER_ON_JOIN)
         .build();
 
     HepPlanner planner = createPlanner(program);
@@ -496,7 +494,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
     mapNewRelToMapOldToNewOutputPos.put(newAggregateRel, combinedMap);
 
     if (produceCorVar) {
-      // AggregaterRel does not change input ordering so corVars will be
+      // AggregateRel does not change input ordering so corVars will be
       // located at the same position as the input newProjectRel.
       mapNewRelToMapCorVarToOutputPos.put(
           newAggregateRel,

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/58ddf6bf/core/src/test/java/net/hydromatic/optiq/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/net/hydromatic/optiq/test/JdbcTest.java b/core/src/test/java/net/hydromatic/optiq/test/JdbcTest.java
index 8a1f509..292a2ef 100644
--- a/core/src/test/java/net/hydromatic/optiq/test/JdbcTest.java
+++ b/core/src/test/java/net/hydromatic/optiq/test/JdbcTest.java
@@ -4002,6 +4002,29 @@ public class JdbcTest {
             "empid=110; deptno=10; name=Theodore; salary=11500.0; commission=250");
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/OPTIQ-313">OPTIQ-313</a>,
+   * "Query decorrelation fails". */
+  @Test public void testJoinInCorrelatedSubquery() {
+    OptiqAssert.that()
+        .with(OptiqAssert.Config.REGULAR)
+        .query(
+            "select *\n"
+            + "from \"hr\".\"depts\" as d\n"
+            + "where \"deptno\" in (\n"
+            + "  select d2.\"deptno\"\n"
+            + "  from \"hr\".\"depts\" as d2\n"
+            + "  join \"hr\".\"emps\" as e2 using (\"deptno\")\n"
+            + "where d.\"deptno\" = d2.\"deptno\")")
+        .convertMatches(new Function1<RelNode, Void>() {
+          public Void apply(RelNode relNode) {
+            String s = RelOptUtil.toString(relNode);
+            assertThat(s, not(containsString("CorrelatorRel")));
+            return null;
+          }
+        });
+  }
+
   /** Tests a correlated scalar sub-query in the SELECT clause.
    *
    * <p>Note that there should be an extra row "empid=200; deptno=20;

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/58ddf6bf/core/src/test/java/net/hydromatic/optiq/test/MaterializationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/net/hydromatic/optiq/test/MaterializationTest.java b/core/src/test/java/net/hydromatic/optiq/test/MaterializationTest.java
index 72fb090..8c6ecd5 100644
--- a/core/src/test/java/net/hydromatic/optiq/test/MaterializationTest.java
+++ b/core/src/test/java/net/hydromatic/optiq/test/MaterializationTest.java
@@ -154,19 +154,6 @@ public class MaterializationTest {
         "select \"empid\" + 1 as x, \"name\" from \"emps\" where \"deptno\" = 10");
   }
 
-  /** Temporary. */
-  @Test public void testFilterQueryOnProjectViewX() {
-    testFilterQueryOnProjectView3();
-    testFilterQueryOnProjectView5();
-    testFilterQueryOnProjectView6();
-    testFilterQueryOnProjectView7();
-    testFilterQueryOnProjectView();
-    testFilterQueryOnProjectView0();
-    testFilterQueryOnProjectView1();
-    testFilterQueryOnProjectView2();
-
-  }
-
   @Test public void testFilterQueryOnProjectView3() {
     checkMaterialize(
         "select \"deptno\" - 10 as \"x\", \"empid\" + 1, \"name\" from \"emps\"",

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/58ddf6bf/core/src/test/java/net/hydromatic/optiq/test/OptiqAssert.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/net/hydromatic/optiq/test/OptiqAssert.java b/core/src/test/java/net/hydromatic/optiq/test/OptiqAssert.java
index ca6df2a..a89523c 100644
--- a/core/src/test/java/net/hydromatic/optiq/test/OptiqAssert.java
+++ b/core/src/test/java/net/hydromatic/optiq/test/OptiqAssert.java
@@ -1119,7 +1119,8 @@ public class OptiqAssert {
       return this;
     }
 
-    @Override public AssertQuery convertContains(String expected) {
+    @Override public AssertQuery convertMatches(
+        Function1<RelNode, Void> checker) {
       return this;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-optiq/blob/58ddf6bf/plus/src/test/java/net/hydromatic/optiq/impl/tpch/TpchTest.java
----------------------------------------------------------------------
diff --git a/plus/src/test/java/net/hydromatic/optiq/impl/tpch/TpchTest.java b/plus/src/test/java/net/hydromatic/optiq/impl/tpch/TpchTest.java
index d9320f4..daa4174 100644
--- a/plus/src/test/java/net/hydromatic/optiq/impl/tpch/TpchTest.java
+++ b/plus/src/test/java/net/hydromatic/optiq/impl/tpch/TpchTest.java
@@ -795,12 +795,11 @@ public class TpchTest {
     checkQuery(1);
   }
 
-  @Ignore("CannotPlanException")
+  @Ignore("slow")
   @Test public void testQuery02() {
     checkQuery(2);
   }
 
-  @Ignore("RelDecorrelator leaves a CorrelatorRel behind")
   @Test public void testQuery02Conversion() {
     query(2)
         .convertMatches(new Function1<RelNode, Void>() {