tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject git commit: TAJO-739: A subquery with the same column alias caused planning error. (hyoungjunkim via hyunsik)
Date Tue, 08 Apr 2014 06:58:24 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 5b0cf0db7 -> 957d2d3f4


TAJO-739: A subquery with the same column alias caused planning error. (hyoungjunkim via hyunsik)


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

Branch: refs/heads/master
Commit: 957d2d3f410de6ed6be3f4ef8dd4121caf3d4994
Parents: 5b0cf0d
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Tue Apr 8 15:57:23 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Tue Apr 8 15:57:40 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                           |  3 +++
 .../org/apache/tajo/engine/planner/LogicalPlan.java   |  2 +-
 .../tajo/engine/planner/logical/ProjectionNode.java   | 14 +++++++++-----
 .../java/org/apache/tajo/master/GlobalEngine.java     |  2 +-
 .../org/apache/tajo/engine/query/TestCaseByCases.java |  7 +++++++
 .../queries/TestCaseByCases/testTAJO739Case.sql       |  5 +++++
 .../results/TestCaseByCases/testTAJO739Case.result    |  7 +++++++
 7 files changed, 33 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/957d2d3f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f53f2a8..214b398 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -306,6 +306,9 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
+    TAJO-739: A subquery with the same column alias caused planning error.
+    (hyoungjunkim via hyunsik)
+
     TAJO-729: PreLogicalPlanVerifier verifies distinct aggregation functions
     incorrectly. (hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/957d2d3f/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
index c6d10d8..a24f25f 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
@@ -313,7 +313,7 @@ public class LogicalPlan {
 
       // The condition (currentNode.getInSchema().contains(column)) means
       // the column can be used at the current node. So, we don't need to find aliase name.
-      if (currentNode != null && !currentNode.getInSchema().contains(column)) {
+      if (currentNode != null && !currentNode.getInSchema().contains(column) &&
currentNode.getType() != NodeType.TABLE_SUBQUERY) {
         List<Column> candidates = TUtil.newList();
         if (block.namedExprsMgr.isAliased(qualifiedName)) {
           String alias = block.namedExprsMgr.getAlias(canonicalName);

http://git-wip-us.apache.org/repos/asf/tajo/blob/957d2d3f/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ProjectionNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ProjectionNode.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ProjectionNode.java
index 4d922ba..e9fd803 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ProjectionNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ProjectionNode.java
@@ -56,7 +56,9 @@ public class ProjectionNode extends UnaryNode implements Projectable {
 	
 	public String toString() {
 	  StringBuilder sb = new StringBuilder("Projection (distinct=").append(distinct);
-    sb.append(", exprs=").append(TUtil.arrayToString(targets)).append(")");
+    if (targets != null) {
+      sb.append(", exprs=").append(TUtil.arrayToString(targets)).append(")");
+    }
 	  return sb.toString();
 	}
 	
@@ -91,10 +93,12 @@ public class ProjectionNode extends UnaryNode implements Projectable {
 
 
     StringBuilder sb = new StringBuilder("Targets: ");
-    for (int i = 0; i < targets.length; i++) {
-      sb.append(targets[i]);
-      if( i < targets.length - 1) {
-        sb.append(", ");
+    if (targets != null) {
+      for (int i = 0; i < targets.length; i++) {
+        sb.append(targets[i]);
+        if (i < targets.length - 1) {
+          sb.append(", ");
+        }
       }
     }
     planStr.addExplan(sb.toString());

http://git-wip-us.apache.org/repos/asf/tajo/blob/957d2d3f/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/GlobalEngine.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/GlobalEngine.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/GlobalEngine.java
index 0d5453c..a56284b 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/GlobalEngine.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/GlobalEngine.java
@@ -202,7 +202,7 @@ public class GlobalEngine extends AbstractService {
 
   public QueryId updateQuery(Session session, String sql) throws IOException, SQLException,
PlanningException {
     try {
-      LOG.info("==========>SQL: " + sql);
+      LOG.info("SQL: " + sql);
       // parse the query
       Expr expr = analyzer.parse(sql);
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/957d2d3f/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
index 2c42b2a..9836a57 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestCaseByCases.java
@@ -60,4 +60,11 @@ public class TestCaseByCases extends QueryTestCaseBase {
     assertResultSet(res);
     cleanupQuery(res);
   }
+
+  @Test
+  public final void testTAJO739Case() throws Exception {
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/957d2d3f/tajo-core/tajo-core-backend/src/test/resources/queries/TestCaseByCases/testTAJO739Case.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestCaseByCases/testTAJO739Case.sql
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestCaseByCases/testTAJO739Case.sql
new file mode 100644
index 0000000..3525621
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestCaseByCases/testTAJO739Case.sql
@@ -0,0 +1,5 @@
+select nation.n_nationkey as n_nationkey,
+       nation.n_name as n_name
+from nation
+inner join (select c_nationkey as n_nationkey from customer) a
+on nation.n_nationkey = a.n_nationkey
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/957d2d3f/tajo-core/tajo-core-backend/src/test/resources/results/TestCaseByCases/testTAJO739Case.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestCaseByCases/testTAJO739Case.result
b/tajo-core/tajo-core-backend/src/test/resources/results/TestCaseByCases/testTAJO739Case.result
new file mode 100644
index 0000000..83ae904
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestCaseByCases/testTAJO739Case.result
@@ -0,0 +1,7 @@
+n_nationkey,n_name
+-------------------------------
+1,ARGENTINA
+3,CANADA
+4,EGYPT
+13,JORDAN
+15,MOROCCO
\ No newline at end of file


Mime
View raw message