tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [5/7] tajo git commit: TAJO-1574: Fix NPE on natural join.
Date Mon, 27 Apr 2015 14:17:43 GMT
TAJO-1574: Fix NPE on natural join.

Closes #548

Signed-off-by: Jihoon Son <jihoonson@apache.org>


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

Branch: refs/heads/index_support
Commit: 1971d85fce473da5cec407adecf89117253eca45
Parents: b50831f
Author: Dongjoon Hyun <dongjoon@apache.org>
Authored: Mon Apr 27 22:36:48 2015 +0900
Committer: Jihoon Son <jihoonson@apache.org>
Committed: Mon Apr 27 22:36:48 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |  3 +++
 .../main/java/org/apache/tajo/algebra/Join.java |  4 ++-
 .../apache/tajo/engine/query/TestJoinQuery.java | 13 ++++++++++
 .../queries/TestJoinQuery/testNaturalJoin.sql   |  3 +++
 .../TestJoinQuery/testNaturalJoin.result        | 27 ++++++++++++++++++++
 .../tajo/plan/algebra/BaseAlgebraVisitor.java   |  4 ++-
 6 files changed, 52 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/1971d85f/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index b6488c4..7b16e11 100644
--- a/CHANGES
+++ b/CHANGES
@@ -104,6 +104,9 @@ Release 0.11.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1574: Fix NPE on natural join.
+    (Contributed by Dongjoon Hyun, Committed by jihoon)
+
     TAJO-1581: Does not update last state of query stage in non-hash shuffle.
     (jinho)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/1971d85f/tajo-algebra/src/main/java/org/apache/tajo/algebra/Join.java
----------------------------------------------------------------------
diff --git a/tajo-algebra/src/main/java/org/apache/tajo/algebra/Join.java b/tajo-algebra/src/main/java/org/apache/tajo/algebra/Join.java
index 2b1f344..6b3ce61 100644
--- a/tajo-algebra/src/main/java/org/apache/tajo/algebra/Join.java
+++ b/tajo-algebra/src/main/java/org/apache/tajo/algebra/Join.java
@@ -96,7 +96,9 @@ public class Join extends BinaryOperator {
   public Object clone() throws CloneNotSupportedException {
     Join join = (Join) super.clone();
     join.joinType = joinType;
-    join.joinQual = (Expr) joinQual.clone();
+    if (joinQual != null) {
+      join.joinQual = (Expr) joinQual.clone();
+    }
     if (joinColumns != null) {
       join.joinColumns = new ColumnReferenceExpr[joinColumns.length];
       for (ColumnReferenceExpr colume : joinColumns) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/1971d85f/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 1078943..7ac25ea 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
@@ -18,6 +18,7 @@
 
 package org.apache.tajo.engine.query;
 
+import junit.framework.Assert;
 import org.apache.tajo.IntegrationTest;
 import org.apache.tajo.QueryTestCaseBase;
 import org.apache.tajo.TajoConstants;
@@ -1191,4 +1192,16 @@ public class TestJoinQuery extends QueryTestCaseBase {
     assertResultSet(res);
     cleanupQuery(res);
   }
+
+  @Test
+  public final void testNaturalJoin() throws Exception {
+    ResultSet res = null;
+    try {
+      res = executeQuery();
+    } catch (Exception e) {
+      Assert.fail();
+    }
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/1971d85f/tajo-core/src/test/resources/queries/TestJoinQuery/testNaturalJoin.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testNaturalJoin.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testNaturalJoin.sql
new file mode 100644
index 0000000..fcbdcdc
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testNaturalJoin.sql
@@ -0,0 +1,3 @@
+select n1.n_name, n2.n_name
+from nation n1 natural join nation n2
+order by n2.n_name;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/1971d85f/tajo-core/src/test/resources/results/TestJoinQuery/testNaturalJoin.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testNaturalJoin.result b/tajo-core/src/test/resources/results/TestJoinQuery/testNaturalJoin.result
new file mode 100644
index 0000000..fa5a71e
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestJoinQuery/testNaturalJoin.result
@@ -0,0 +1,27 @@
+n_name,n_name
+-------------------------------
+ALGERIA,ALGERIA
+ARGENTINA,ARGENTINA
+BRAZIL,BRAZIL
+CANADA,CANADA
+CHINA,CHINA
+EGYPT,EGYPT
+ETHIOPIA,ETHIOPIA
+FRANCE,FRANCE
+GERMANY,GERMANY
+INDIA,INDIA
+INDONESIA,INDONESIA
+IRAN,IRAN
+IRAQ,IRAQ
+JAPAN,JAPAN
+JORDAN,JORDAN
+KENYA,KENYA
+MOROCCO,MOROCCO
+MOZAMBIQUE,MOZAMBIQUE
+PERU,PERU
+ROMANIA,ROMANIA
+RUSSIA,RUSSIA
+SAUDI ARABIA,SAUDI ARABIA
+UNITED KINGDOM,UNITED KINGDOM
+UNITED STATES,UNITED STATES
+VIETNAM,VIETNAM
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/1971d85f/tajo-plan/src/main/java/org/apache/tajo/plan/algebra/BaseAlgebraVisitor.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/algebra/BaseAlgebraVisitor.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/algebra/BaseAlgebraVisitor.java
index bd10514..eb11f33 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/algebra/BaseAlgebraVisitor.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/algebra/BaseAlgebraVisitor.java
@@ -364,7 +364,9 @@ public class BaseAlgebraVisitor<CONTEXT, RESULT> implements AlgebraVisitor<CONTE
   @Override
   public RESULT visitJoin(CONTEXT ctx, Stack<Expr> stack, Join expr) throws PlanningException
{
     stack.push(expr);
-    visit(ctx, stack, expr.getQual());
+    if (expr.getQual() != null) {
+      visit(ctx, stack, expr.getQual());
+    }
     visit(ctx, stack, expr.getLeft());
     RESULT result = visit(ctx, stack, expr.getRight());
     stack.pop();


Mime
View raw message