You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2015/09/07 14:15:49 UTC

tajo git commit: TAJO-1610: Cannot find column when the same name is used for table and database.

Repository: tajo
Updated Branches:
  refs/heads/master 8db6928a4 -> da40cb080


TAJO-1610: Cannot find column when the same name is used for table and database.

Closes #735


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

Branch: refs/heads/master
Commit: da40cb080facf468510392e6399a38acdf0bdffb
Parents: 8db6928
Author: Hyunsik Choi <hy...@apache.org>
Authored: Mon Sep 7 21:13:48 2015 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Mon Sep 7 21:13:48 2015 +0900

----------------------------------------------------------------------
 CHANGES                                                  |  3 +++
 .../apache/tajo/engine/query/TestSelectNestedRecord.java | 11 +++++++++++
 .../queries/TestSelectNestedRecord/testTAJO_1610.sql     |  1 +
 .../results/TestSelectNestedRecord/testTAJO_1610.result  |  6 ++++++
 .../org/apache/tajo/plan/nameresolver/NameResolver.java  |  4 ++--
 5 files changed, 23 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/da40cb08/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 6ee478b..203db8c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -249,6 +249,9 @@ Release 0.11.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1610: Cannot find column when the same name is used for table 
+    and database. (hyunsik)
+
     TAJO-1800: WHERE clause is ignored with UNION. (hyunsik)
 
     TAJO-1815: Catalog store initialization with PostgreSQL failed.

http://git-wip-us.apache.org/repos/asf/tajo/blob/da40cb08/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectNestedRecord.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectNestedRecord.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectNestedRecord.java
index 41df0fa..da18b0a 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectNestedRecord.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectNestedRecord.java
@@ -70,6 +70,17 @@ public class TestSelectNestedRecord extends QueryTestCaseBase {
   }
 
   @Test
+  public final void testTAJO_1610() throws Exception {
+    executeString("CREATE DATABASE tweets").close();
+    List<String> tables = executeDDL("tweets_ddl.sql", "tweets", "tweets.tweets");
+    assertEquals(TUtil.newList("tweets.tweets"), tables);
+
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
+
+  @Test
   public final void testNestedFieldAsGroupbyKey1() throws Exception {
     List<String> tables = executeDDL("tweets_ddl.sql", "tweets", "tweets");
     assertEquals(TUtil.newList("tweets"), tables);

http://git-wip-us.apache.org/repos/asf/tajo/blob/da40cb08/tajo-core-tests/src/test/resources/queries/TestSelectNestedRecord/testTAJO_1610.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSelectNestedRecord/testTAJO_1610.sql b/tajo-core-tests/src/test/resources/queries/TestSelectNestedRecord/testTAJO_1610.sql
new file mode 100644
index 0000000..e0390ae
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSelectNestedRecord/testTAJO_1610.sql
@@ -0,0 +1 @@
+select "text" from tweets.tweets limit 10;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/da40cb08/tajo-core-tests/src/test/resources/results/TestSelectNestedRecord/testTAJO_1610.result
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/results/TestSelectNestedRecord/testTAJO_1610.result b/tajo-core-tests/src/test/resources/results/TestSelectNestedRecord/testTAJO_1610.result
new file mode 100644
index 0000000..12ca187
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/results/TestSelectNestedRecord/testTAJO_1610.result
@@ -0,0 +1,6 @@
+text
+-------------------------------
+Aggressive Ponytail #freebandnames
+Thee Namaste Nerdz. #FreeBandNames
+Mexican Heaven, Mexican Hell #freebandnames
+The Foolish Mortals #freebandnames
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/da40cb08/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java b/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java
index 7eb22d7..b41ef76 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java
@@ -349,7 +349,7 @@ public abstract class NameResolver {
     }
 
     // check for tbname.column_name.nested_field
-    if (qualifierParts.length >= 1) {
+    if (columnNamePosition < 0 && qualifierParts.length >= 1) {
       RelationNode rel = lookupTable(block, qualifierParts[0]);
       if (rel != null) {
         guessedRelations.add(rel);
@@ -358,7 +358,7 @@ public abstract class NameResolver {
     }
 
     // column.nested_fieldX...
-    if (guessedRelations.size() == 0 && qualifierParts.length > 0) {
+    if (columnNamePosition < 0 && guessedRelations.size() == 0 && qualifierParts.length > 0) {
       Collection<RelationNode> rels = lookupTableByColumns(block, StringUtils.join(qualifierParts,
           NestedPathUtil.PATH_DELIMITER, 0));