tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [05/17] git commit: TAJO-975: alias name which is the same to existing column name may cause NPE during PPD.
Date Mon, 11 Aug 2014 08:11:34 GMT
TAJO-975: alias name which is the same to existing column name may cause NPE during PPD.

Closes #92


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

Branch: refs/heads/index_support
Commit: ae384685f5c16853d47cc4a9a611729dfe2b14fc
Parents: 6b16264
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Mon Aug 4 15:33:43 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Mon Aug 4 15:33:43 2014 +0900

----------------------------------------------------------------------
 CHANGES                                          |  5 ++++-
 .../planner/rewrite/ProjectionPushDownRule.java  | 10 ++++++++++
 .../tajo/engine/query/TestSelectQuery.java       |  9 +++++++++
 .../testSelectColumnAliasExistingInRelation3.sql | 19 +++++++++++++++++++
 ...stSelectColumnAliasExistingInRelation3.result | 11 +++++++++++
 5 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/ae384685/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index f98da28..61593a2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -103,7 +103,10 @@ Release 0.9.0 - unreleased
 
   BUG FIXES
     
-    TAJO-979: Dividing float value by zero should throw "Divide by zero 
+    TAJO-975: alias name which is the same to existing column name may cause
+    NPE during PPD. (hyunsik)
+
+    TAJO-979: Dividing float value by zero should throw "Divide by zero
     Exception" (Hyoungjun Kim via hyunsik)
 
     TAJO-978: RoundFloat8 should return Float8Datum type. (Hyoungjun Kim via 

http://git-wip-us.apache.org/repos/asf/tajo/blob/ae384685/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 e5a329d..4a12d99 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
@@ -191,6 +191,7 @@ public class ProjectionPushDownRule extends
       // if a name already exists, it only just keeps an actual
       // expression instead of a column reference.
       if (nameToIdBiMap.containsKey(specifiedName)) {
+
         int refId = nameToIdBiMap.get(specifiedName);
         EvalNode found = idToEvalBiMap.get(refId);
         if (found != null) {
@@ -204,7 +205,16 @@ public class ProjectionPushDownRule extends
             }
 
             if (found.getType() == EvalType.FIELD) {
+              Integer daggling = idToEvalBiMap.inverse().get(evalNode);
               idToEvalBiMap.forcePut(refId, evalNode);
+              if (daggling != null) {
+                String name = getPrimaryName(daggling);
+                idToNamesMap.remove(daggling);
+                nameToIdBiMap.put(name, refId);
+                if (!idToNamesMap.get(refId).contains(name)) {
+                  TUtil.putToNestedList(idToNamesMap, refId, name);
+                }
+              }
             }
           }
         }

http://git-wip-us.apache.org/repos/asf/tajo/blob/ae384685/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
index 2fd7b14..50d274d 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
@@ -138,6 +138,15 @@ public class TestSelectQuery extends QueryTestCaseBase {
     cleanupQuery(res);
   }
 
+  @Test
+  public final void testSelectColumnAliasExistingInRelation3() throws Exception {
+    // This is a reproduction code and validator of TAJO-975 Bug
+    // Please see TAJO-975 in order to know this test in detail.
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
+
 
   @Test
   public final void testSelectSameConstantsWithDifferentAliases() throws Exception {

http://git-wip-us.apache.org/repos/asf/tajo/blob/ae384685/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectColumnAliasExistingInRelation3.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectColumnAliasExistingInRelation3.sql
b/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectColumnAliasExistingInRelation3.sql
new file mode 100644
index 0000000..98336b7
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectColumnAliasExistingInRelation3.sql
@@ -0,0 +1,19 @@
+SELECT l_orderkey FROM (
+
+-- actual test query
+  SELECT
+    T1.l_orderkey
+  FROM
+    LINEITEM
+  INNER JOIN (
+    SELECT
+      T1.l_orderkey
+    FROM (
+      SELECT
+        LINEITEM.l_orderkey AS l_orderkey
+      FROM
+        LINEITEM
+    ) T1
+  ) T1 ON LINEITEM.l_orderkey=T1.l_orderkey
+
+) A ORDER BY l_orderkey; -- for determinant query result
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/ae384685/tajo-core/src/test/resources/results/TestSelectQuery/testSelectColumnAliasExistingInRelation3.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestSelectQuery/testSelectColumnAliasExistingInRelation3.result
b/tajo-core/src/test/resources/results/TestSelectQuery/testSelectColumnAliasExistingInRelation3.result
new file mode 100644
index 0000000..3b40488
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestSelectQuery/testSelectColumnAliasExistingInRelation3.result
@@ -0,0 +1,11 @@
+l_orderkey
+-------------------------------
+1
+1
+1
+1
+2
+3
+3
+3
+3
\ No newline at end of file


Mime
View raw message