DRILL-1150: Only push expressions in equal join predicate down into projects. 
Fix is in Optiq.


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/415506b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/415506b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/415506b1

Branch: refs/heads/master
Commit: 415506b1056093a62ae5dd7a8df7faa704ff77c3
Parents: a4c0ba7
Author: Jinfeng Ni <j...@maprtech.com>
Authored: Thu Jul 17 09:31:10 2014 -0700
Committer: Jinfeng Ni <j...@maprtech.com>
Committed: Sun Jul 20 22:20:46 2014 -0700

----------------------------------------------------------------------
 .../org/apache/drill/TestExampleQueries.java    | 36 ++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/415506b1/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 cfe2a88..ab4ffcb 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
@@ -50,6 +50,42 @@ public class TestExampleQueries extends BaseTestQuery{
   }
 
   @Test
+  public void testPushExpInJoinConditionInnerJoin() throws Exception {
+    test("select a.n_nationkey from cp.`tpch/nation.parquet` a join 
cp.`tpch/region.parquet` b " + "" +
+        " on a.n_regionkey + 100  = b.r_regionkey + 200" +      // expressions 
in both sides of equal join filter
+        "   and (substr(a.n_name,1,3)= 'L1' or substr(a.n_name,2,2) = 'L2') " 
+  // left filter
+        "   and (substr(b.r_name,1,3)= 'R1' or substr(b.r_name,2,2) = 'R2') " 
+  // right filter
+        "   and (substr(a.n_name,2,3)= 'L3' or substr(b.r_name,3,2) = 
'R3');");  // non-equal join filter
+  }
+
+  @Test
+  public void testPushExpInJoinConditionWhere() throws Exception {
+    test("select a.n_nationkey from cp.`tpch/nation.parquet` a , 
cp.`tpch/region.parquet` b " + "" +
+        " where a.n_regionkey + 100  = b.r_regionkey + 200" +      // 
expressions in both sides of equal join filter
+        "   and (substr(a.n_name,1,3)= 'L1' or substr(a.n_name,2,2) = 'L2') " 
+  // left filter
+        "   and (substr(b.r_name,1,3)= 'R1' or substr(b.r_name,2,2) = 'R2') " 
+  // right filter
+        "   and (substr(a.n_name,2,3)= 'L3' or substr(b.r_name,3,2) = 
'R3');");  // non-equal join filter
+  }
+
+  @Test
+  public void testPushExpInJoinConditionLeftJoin() throws Exception {
+    test("select a.n_nationkey from cp.`tpch/nation.parquet` a left join 
cp.`tpch/region.parquet` b " + "" +
+        " on a.n_regionkey +100 = b.r_regionkey +200 " +        // expressions 
in both sides of equal join filter
+        "   and (substr(a.n_name,1,3)= 'L1' or substr(a.n_name,2,2) = 'L2') " 
+  // left filter
+        "   and (substr(b.r_name,1,3)= 'R1' or substr(b.r_name,2,2) = 'R2') " 
+  // right filter
+        "   and (substr(a.n_name,2,3)= 'L3' or substr(b.r_name,3,2) = 
'R3');");  // non-equal join filter
+  }
+
+  @Test
+  public void testPushExpInJoinConditionRightJoin() throws Exception {
+    test("select a.n_nationkey from cp.`tpch/nation.parquet` a right join 
cp.`tpch/region.parquet` b " + "" +
+        " on a.n_regionkey +100 = b.r_regionkey +200 " +        // expressions 
in both sides of equal join filter
+        "   and (substr(a.n_name,1,3)= 'L1' or substr(a.n_name,2,2) = 'L2') " 
+  // left filter
+        "   and (substr(b.r_name,1,3)= 'R1' or substr(b.r_name,2,2) = 'R2') " 
+  // right filter
+        "   and (substr(a.n_name,2,3)= 'L3' or substr(b.r_name,3,2) = 
'R3');");  // non-equal join filter
+  }
+
+  @Test
   public void testCaseReturnValueVarChar() throws Exception{
     test("select case when employee_id < 1000 then 'ABC' else 'DEF' end from 
cp.`employee.json` limit 5");
   }

Reply via email to