tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject git commit: TAJO-568: Union query with the same alias names cause NPE.
Date Mon, 03 Feb 2014 15:01:38 GMT
Updated Branches:
  refs/heads/master 10c599f4b -> db2f733a6


TAJO-568: Union query with the same alias names cause NPE.


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

Branch: refs/heads/master
Commit: db2f733a6753c78de673a339e9cba1c817201c76
Parents: 10c599f
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Tue Feb 4 00:01:19 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Tue Feb 4 00:01:19 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../engine/planner/LogicalPlanPreprocessor.java |  2 +-
 .../tajo/engine/planner/TestLogicalPlan.java    |  4 ++--
 .../tajo/engine/query/TestUnionQuery.java       |  7 ++++++
 .../testUnionWithSameAliasNames.sql             | 25 ++++++++++++++++++++
 .../testUnionWithSameAliasNames.result          | 12 ++++++++++
 6 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/db2f733a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 10d002d..e6f34a0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -243,6 +243,8 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
+    TAJO-568: Union query with the same alias names cause NPE. (hyunsik)
+
     TAJO-570: InvalidOperationException in outer join with constant values.
     (hyunsik)
 

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/db2f733a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
index 586ef68..099e462 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlanPreprocessor.java
@@ -250,7 +250,7 @@ class LogicalPlanPreprocessor extends BaseAlgebraVisitor<LogicalPlanPreprocessor
     PreprocessContext newContext;
     // Note: TableSubQuery always has a table name.
     // SELECT .... FROM (SELECT ...) TB_NAME <-
-    newContext = new PreprocessContext(ctx, ctx.plan.newAndGetBlock(expr.getName()));
+    newContext = new PreprocessContext(ctx, ctx.plan.newQueryBlock());
     LogicalNode child = super.visitTableSubQuery(newContext, stack, expr);
 
     // a table subquery should be dealt as a relation.

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/db2f733a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
index 208b18d..bfd1f81 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
@@ -85,8 +85,8 @@ public class TestLogicalPlan {
   public final void testQueryBlockGraph() {
     LogicalPlan plan = new LogicalPlan(planner);
     LogicalPlan.QueryBlock root = plan.newAndGetBlock(LogicalPlan.ROOT_BLOCK);
-    LogicalPlan.QueryBlock new1 = plan.newAndGetBlock("@new1");
-    LogicalPlan.QueryBlock new2 = plan.newAndGetBlock("@new2");
+    LogicalPlan.QueryBlock new1 = plan.newQueryBlock();
+    LogicalPlan.QueryBlock new2 = plan.newQueryBlock();
 
     plan.getQueryBlockGraph().addEdge(new1.getName(), root.getName(),
         new LogicalPlan.BlockEdge(new1, root, BlockType.TableSubQuery));

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/db2f733a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestUnionQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestUnionQuery.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestUnionQuery.java
index 169ed23..22830bf 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestUnionQuery.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestUnionQuery.java
@@ -126,4 +126,11 @@ public class TestUnionQuery extends QueryTestCaseBase {
     assertResultSet(res);
     cleanupQuery(res);
   }
+
+  @Test
+  public final void testUnionWithSameAliasNames() throws Exception {
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/db2f733a/tajo-core/tajo-core-backend/src/test/resources/queries/TestUnionQuery/testUnionWithSameAliasNames.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestUnionQuery/testUnionWithSameAliasNames.sql
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestUnionQuery/testUnionWithSameAliasNames.sql
new file mode 100644
index 0000000..c39940c
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestUnionQuery/testUnionWithSameAliasNames.sql
@@ -0,0 +1,25 @@
+select
+  *
+from (
+  select
+    l_orderkey
+  from (
+    select
+      l_orderkey
+    from
+      lineitem
+  ) l1
+
+  union
+
+  select
+    l_orderkey
+  from (
+    select
+      l_orderkey
+    from
+      lineitem
+  ) l1
+) t1
+order by
+  l_orderkey;

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/db2f733a/tajo-core/tajo-core-backend/src/test/resources/results/TestUnionQuery/testUnionWithSameAliasNames.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestUnionQuery/testUnionWithSameAliasNames.result
b/tajo-core/tajo-core-backend/src/test/resources/results/TestUnionQuery/testUnionWithSameAliasNames.result
new file mode 100644
index 0000000..d269baa
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestUnionQuery/testUnionWithSameAliasNames.result
@@ -0,0 +1,12 @@
+l_orderkey
+-------------------------------
+1
+1
+1
+1
+2
+2
+3
+3
+3
+3
\ No newline at end of file


Mime
View raw message