tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [44/50] [abbrv] git commit: TAJO-891: Complex join conditions with UNION or inline should be supported.
Date Wed, 09 Jul 2014 04:11:01 GMT
TAJO-891: Complex join conditions with UNION or inline should be supported.

Closes #49


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/eae4c132
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/eae4c132
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/eae4c132

Branch: refs/heads/window_function
Commit: eae4c132363a63240d93c5522e48b44e45d9553d
Parents: 0953d71
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Thu Jul 3 22:52:40 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Thu Jul 3 22:52:40 2014 +0900

----------------------------------------------------------------------
 CHANGES                                         |  6 +++
 .../java/org/apache/tajo/catalog/Schema.java    |  2 +-
 .../apache/tajo/engine/planner/PlannerUtil.java |  2 +-
 .../planner/rewrite/ProjectionPushDownRule.java | 12 ++---
 .../apache/tajo/engine/query/TestJoinQuery.java | 21 ++++++++
 .../TestJoinQuery/testComplexJoinCondition5.sql |  6 +++
 .../TestJoinQuery/testComplexJoinCondition6.sql |  6 +++
 .../TestJoinQuery/testComplexJoinCondition7.sql |  6 +++
 .../testComplexJoinCondition5.result            | 29 ++++++++++
 .../testComplexJoinCondition6.result            | 56 ++++++++++++++++++++
 .../testComplexJoinCondition7.result            | 56 ++++++++++++++++++++
 11 files changed, 193 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 06f6ec1..d12b1e8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -74,6 +74,12 @@ Release 0.9.0 - unreleased
 
   BUG FIXES
 
+    TAJO-891: Complex join conditions with UNION or inline should be supported.
+    (hyunsik)
+    
+    TAJO-899: Nested now() has different value for each task. (Hyoungjun Kim 
+    via hyunsik)
+
     TAJO-894: Left outer join with partitioned large table and small table 
     returns empty result. (Hyoungjun Kim via hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
index b2dde3d..35d2fe9 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Schema.java
@@ -230,7 +230,7 @@ public class Schema implements ProtoObject<SchemaProto>, Cloneable,
GsonObject {
       return true;
     }
     if (fieldsByName.containsKey(name)) {
-      if (fieldsByName.size() > 1) {
+      if (fieldsByName.get(name).size() > 1) {
         throw new RuntimeException("Ambiguous Column name");
       }
       return true;

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java
index 4037df3..1d8fd0f 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/PlannerUtil.java
@@ -599,7 +599,7 @@ public class PlannerUtil {
           for (int j = 0; j < schemas.length; j++) {
             // check whether the column is for either outer or inner
             // 0 is outer, and 1 is inner
-            if (schemas[j].containsByQualifiedName(column.getQualifiedName())) {
+            if (schemas[j].contains(column.getQualifiedName())) {
               pair[j] = column;
             }
           }

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/ProjectionPushDownRule.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/ProjectionPushDownRule.java
b/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/ProjectionPushDownRule.java
index 8d80d39..4e4b5c3 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/ProjectionPushDownRule.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/rewrite/ProjectionPushDownRule.java
@@ -979,7 +979,7 @@ public class ProjectionPushDownRule extends
       newContext.addExpr(target);
     }
 
-    for (Iterator<Target> it = getFilteredTarget(targets, context.requiredSet); it.hasNext();)
{
+    for (Iterator<Target> it = context.targetListMgr.getFilteredTargets(newContext.requiredSet);
it.hasNext();) {
       Target target = it.next();
 
       if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node))
{
@@ -1002,8 +1002,6 @@ public class ProjectionPushDownRule extends
     node.setSubQuery(child);
     stack.pop();
 
-    Context newContext = new Context(upperContext);
-
     Target [] targets;
     if (node.hasTargets()) {
       targets = node.getTargets();
@@ -1012,17 +1010,17 @@ public class ProjectionPushDownRule extends
     }
 
     LinkedHashSet<Target> projectedTargets = Sets.newLinkedHashSet();
-    for (Iterator<Target> it = getFilteredTarget(targets, newContext.requiredSet);
it.hasNext();) {
+    for (Iterator<Target> it = getFilteredTarget(targets, upperContext.requiredSet);
it.hasNext();) {
       Target target = it.next();
-      childContext.addExpr(target);
+      upperContext.addExpr(target);
     }
 
-    for (Iterator<Target> it = getFilteredTarget(targets, upperContext.requiredSet);
it.hasNext();) {
+    for (Iterator<Target> it = upperContext.targetListMgr.getFilteredTargets(upperContext.requiredSet);
it.hasNext();) {
       Target target = it.next();
 
       if (LogicalPlanner.checkIfBeEvaluatedAtRelation(block, target.getEvalTree(), node))
{
         projectedTargets.add(target);
-        childContext.targetListMgr.markAsEvaluated(target);
+        upperContext.targetListMgr.markAsEvaluated(target);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
index 8f8f86b..13a0b2b 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
@@ -1012,6 +1012,27 @@ public class TestJoinQuery extends QueryTestCaseBase {
   }
 
   @Test
+  public void testComplexJoinCondition5() throws Exception {
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
+
+  @Test
+  public void testComplexJoinCondition6() throws Exception {
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
+
+  @Test
+  public void testComplexJoinCondition7() throws Exception {
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
+
+  @Test
   public void testFullOuterJoinWithEmptyIntermediateData() throws Exception {
     ResultSet res = executeString(
         "select a.l_orderkey \n" +

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition5.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition5.sql
b/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition5.sql
new file mode 100644
index 0000000..f604bc7
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition5.sql
@@ -0,0 +1,6 @@
+select
+  n1.n_nationkey,
+  substr(n1.n_name, 1, 4) name1,
+  substr(n2.n_name, 1, 4) name2
+from nation n1 join (select * from nation) n2 on substr(n1.n_name, 1, 4) = substr(n2.n_name,
1, 4)
+order by n1.n_nationkey;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition6.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition6.sql
b/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition6.sql
new file mode 100644
index 0000000..704b821
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition6.sql
@@ -0,0 +1,6 @@
+select
+  n1.n_nationkey,
+  substr(n1.n_name, 1, 4) name1,
+  substr(n2.n_name, 1, 4) name2
+from nation n1 join (select * from nation union select * from nation) n2 on substr(n1.n_name,
1, 4) = substr(n2.n_name, 1, 4)
+order by n1.n_nationkey;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition7.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition7.sql
b/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition7.sql
new file mode 100644
index 0000000..ddd669c
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testComplexJoinCondition7.sql
@@ -0,0 +1,6 @@
+select
+  n1.n_nationkey,
+  n1.n_name,
+  n2.n_name
+from nation n1 join (select * from nation union select * from nation) n2 on substr(n1.n_name,
1, 4) = substr(n2.n_name, 1, 4)
+order by n1.n_nationkey;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition5.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition5.result
b/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition5.result
new file mode 100644
index 0000000..325375d
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition5.result
@@ -0,0 +1,29 @@
+n_nationkey,name1,name2
+-------------------------------
+0,ALGE,ALGE
+1,ARGE,ARGE
+2,BRAZ,BRAZ
+3,CANA,CANA
+4,EGYP,EGYP
+5,ETHI,ETHI
+6,FRAN,FRAN
+7,GERM,GERM
+8,INDI,INDI
+9,INDO,INDO
+10,IRAN,IRAN
+11,IRAQ,IRAQ
+12,JAPA,JAPA
+13,JORD,JORD
+14,KENY,KENY
+15,MORO,MORO
+16,MOZA,MOZA
+17,PERU,PERU
+18,CHIN,CHIN
+19,ROMA,ROMA
+20,SAUD,SAUD
+21,VIET,VIET
+22,RUSS,RUSS
+23,UNIT,UNIT
+23,UNIT,UNIT
+24,UNIT,UNIT
+24,UNIT,UNIT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition6.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition6.result
b/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition6.result
new file mode 100644
index 0000000..82158bc
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition6.result
@@ -0,0 +1,56 @@
+n_nationkey,name1,name2
+-------------------------------
+0,ALGE,ALGE
+0,ALGE,ALGE
+1,ARGE,ARGE
+1,ARGE,ARGE
+2,BRAZ,BRAZ
+2,BRAZ,BRAZ
+3,CANA,CANA
+3,CANA,CANA
+4,EGYP,EGYP
+4,EGYP,EGYP
+5,ETHI,ETHI
+5,ETHI,ETHI
+6,FRAN,FRAN
+6,FRAN,FRAN
+7,GERM,GERM
+7,GERM,GERM
+8,INDI,INDI
+8,INDI,INDI
+9,INDO,INDO
+9,INDO,INDO
+10,IRAN,IRAN
+10,IRAN,IRAN
+11,IRAQ,IRAQ
+11,IRAQ,IRAQ
+12,JAPA,JAPA
+12,JAPA,JAPA
+13,JORD,JORD
+13,JORD,JORD
+14,KENY,KENY
+14,KENY,KENY
+15,MORO,MORO
+15,MORO,MORO
+16,MOZA,MOZA
+16,MOZA,MOZA
+17,PERU,PERU
+17,PERU,PERU
+18,CHIN,CHIN
+18,CHIN,CHIN
+19,ROMA,ROMA
+19,ROMA,ROMA
+20,SAUD,SAUD
+20,SAUD,SAUD
+21,VIET,VIET
+21,VIET,VIET
+22,RUSS,RUSS
+22,RUSS,RUSS
+23,UNIT,UNIT
+23,UNIT,UNIT
+23,UNIT,UNIT
+23,UNIT,UNIT
+24,UNIT,UNIT
+24,UNIT,UNIT
+24,UNIT,UNIT
+24,UNIT,UNIT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/eae4c132/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition7.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition7.result
b/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition7.result
new file mode 100644
index 0000000..edd83cd
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestJoinQuery/testComplexJoinCondition7.result
@@ -0,0 +1,56 @@
+n_nationkey,n_name,n_name
+-------------------------------
+0,ALGERIA,ALGERIA
+0,ALGERIA,ALGERIA
+1,ARGENTINA,ARGENTINA
+1,ARGENTINA,ARGENTINA
+2,BRAZIL,BRAZIL
+2,BRAZIL,BRAZIL
+3,CANADA,CANADA
+3,CANADA,CANADA
+4,EGYPT,EGYPT
+4,EGYPT,EGYPT
+5,ETHIOPIA,ETHIOPIA
+5,ETHIOPIA,ETHIOPIA
+6,FRANCE,FRANCE
+6,FRANCE,FRANCE
+7,GERMANY,GERMANY
+7,GERMANY,GERMANY
+8,INDIA,INDIA
+8,INDIA,INDIA
+9,INDONESIA,INDONESIA
+9,INDONESIA,INDONESIA
+10,IRAN,IRAN
+10,IRAN,IRAN
+11,IRAQ,IRAQ
+11,IRAQ,IRAQ
+12,JAPAN,JAPAN
+12,JAPAN,JAPAN
+13,JORDAN,JORDAN
+13,JORDAN,JORDAN
+14,KENYA,KENYA
+14,KENYA,KENYA
+15,MOROCCO,MOROCCO
+15,MOROCCO,MOROCCO
+16,MOZAMBIQUE,MOZAMBIQUE
+16,MOZAMBIQUE,MOZAMBIQUE
+17,PERU,PERU
+17,PERU,PERU
+18,CHINA,CHINA
+18,CHINA,CHINA
+19,ROMANIA,ROMANIA
+19,ROMANIA,ROMANIA
+20,SAUDI ARABIA,SAUDI ARABIA
+20,SAUDI ARABIA,SAUDI ARABIA
+21,VIETNAM,VIETNAM
+21,VIETNAM,VIETNAM
+22,RUSSIA,RUSSIA
+22,RUSSIA,RUSSIA
+23,UNITED KINGDOM,UNITED KINGDOM
+23,UNITED KINGDOM,UNITED STATES
+23,UNITED KINGDOM,UNITED KINGDOM
+23,UNITED KINGDOM,UNITED STATES
+24,UNITED STATES,UNITED KINGDOM
+24,UNITED STATES,UNITED STATES
+24,UNITED STATES,UNITED KINGDOM
+24,UNITED STATES,UNITED STATES
\ No newline at end of file


Mime
View raw message