Repository: tajo
Updated Branches:
  refs/heads/branch-0.11.1 6fb48eff3 -> 7fb0f25e0


TAJO-1977: Cannot recognize the space-contained tablename and databasename.

Signed-off-by: Jihoon Son <[email protected]>


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

Branch: refs/heads/branch-0.11.1
Commit: 7fb0f25e0282bc62ef8d698b93c454c8cd5b1557
Parents: 6fb48ef
Author: Dongkyu Hwangbo <[email protected]>
Authored: Tue Nov 17 11:30:11 2015 +0900
Committer: Jihoon Son <[email protected]>
Committed: Tue Nov 17 11:30:32 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |  3 ++
 .../tsql/commands/ConnectDatabaseCommand.java   | 13 +++++--
 .../cli/tsql/commands/DescTableCommand.java     | 12 +++++--
 .../org/apache/tajo/cli/tsql/TestTajoCli.java   | 36 +++++++++++++++-----
 .../results/TestTajoCli/testDescTable.result    | 27 ---------------
 .../results/TestTajoCli/testDescTable1.result   | 27 +++++++++++++++
 .../results/TestTajoCli/testDescTable2.result   | 27 +++++++++++++++
 7 files changed, 104 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/7fb0f25e/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 40d2269..48f9016 100644
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,9 @@ Release 0.11.1 - unreleased
 
   BUG FIXES
 
+    TAJO-1977: Cannot recognize the space-contained tablename and databasename.
+    (Contributed by Dongkyu Hwangbo, committed by jihoon)
+
     TAJO-1978: Printout message before terminating TSQL.
     (Contributed by Dongkyu Hwangbo, committed by jaehwa)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/7fb0f25e/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
----------------------------------------------------------------------
diff --git 
a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
 
b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
index a997051..647cbbd 100644
--- 
a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
+++ 
b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/ConnectDatabaseCommand.java
@@ -45,8 +45,17 @@ public class ConnectDatabaseCommand extends TajoShellCommand 
{
       context.getOutput().write(String.format("You are now connected to 
database \"%s\" as user \"%s\".%n",
           client.getCurrentDatabase(), client.getUserInfo().getUserName()));
 
-    } else if (cmd.length == 2) {
-      final String databaseName = cmd[1].replace("\"", "");
+    } else if (cmd.length >= 2) {
+
+      StringBuilder databaseNameMaker = new StringBuilder();
+      for (int i = 1; i < cmd.length; i++) {
+        if (i != 1) {
+          databaseNameMaker.append(" ");
+        }
+        databaseNameMaker.append(cmd[i]);
+      }
+
+      final String databaseName = databaseNameMaker.toString().replace("\"", 
"");
 
       try {
         client.selectDatabase(databaseName);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7fb0f25e/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
----------------------------------------------------------------------
diff --git 
a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
 
b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
index 55553aa..12d23cf 100644
--- 
a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
+++ 
b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/commands/DescTableCommand.java
@@ -47,9 +47,15 @@ public class DescTableCommand extends TajoShellCommand {
 
   @Override
   public void invoke(String[] cmd) throws TajoException {
-    if (cmd.length == 2) {
-      String tableName = cmd[1];
-      tableName = tableName.replace("\"", "");
+    if (cmd.length >= 2) {
+      StringBuilder tableNameMaker = new StringBuilder();
+      for (int i = 1; i < cmd.length; i++) {
+        if (i != 1) {
+          tableNameMaker.append(" ");
+        }
+        tableNameMaker.append(cmd[i]);
+      }
+      String tableName = tableNameMaker.toString().replace("\"", "");
       TableDesc desc = client.getTableDesc(tableName);
       if (desc == null) {
         context.getOutput().println("Did not find any relation named \"" + 
tableName + "\"");

http://git-wip-us.apache.org/repos/asf/tajo/blob/7fb0f25e/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
----------------------------------------------------------------------
diff --git 
a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java 
b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
index ad2d50b..2988fd3 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
@@ -190,14 +190,13 @@ public class TestTajoCli {
     assertOutputResult(consoleResult);
   }
 
-  @Test
-  public void testConnectDatabase() throws Exception {
+  public void verifyConnectDatabase(String testDatabaseName) throws Exception {
     String databaseName;
 
     if (cluster.isHiveCatalogStoreRunning()) {
-      databaseName = "TEST_CONNECTION_DATABASE".toLowerCase();
+      databaseName = testDatabaseName.toLowerCase();
     } else {
-      databaseName = "TEST_CONNECTION_DATABASE";
+      databaseName = testDatabaseName;
     }
     String sql = "create database \"" + databaseName + "\";";
 
@@ -213,6 +212,16 @@ public class TestTajoCli {
     assertEquals(databaseName, tajoCli.getContext().getCurrentDatabase());
   }
 
+  @Test
+  public void testConnectDatabase() throws Exception {
+    verifyConnectDatabase("TEST_CONNECTION_DATABASE");
+  }
+
+  @Test
+  public void testConnectDatabaseNamedWithSpace() throws Exception {
+    verifyConnectDatabase("TEST CONNECTION DATABASE");
+  }
+
   private void verifyDescTable(String sql, String tableName, String 
resultFileName) throws Exception {
     setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, 
TajoCliOutputTestFormatter.class.getName());
     tajoCli.executeScript(sql);
@@ -228,17 +237,26 @@ public class TestTajoCli {
     }
   }
 
-  @Test
-  public void testDescTable() throws Exception {
+  public void testDescTable(String testTableName, String resultFileName) 
throws Exception {
     String tableName;
     if (cluster.isHiveCatalogStoreRunning()) {
-      tableName = "TEST_DESC_TABLE".toLowerCase();
+      tableName = testTableName.toLowerCase();
     } else {
-      tableName = "TEST_DESC_TABLE";
+      tableName = testTableName;
     }
 
     String sql = "create table \"" + tableName + "\" (col1 int4, col2 int4);";
-    verifyDescTable(sql, tableName, "testDescTable.result");
+    verifyDescTable(sql, tableName, resultFileName);
+  }
+
+  @Test
+  public void testDescTable() throws Exception {
+    testDescTable("TEST_DESC_TABLE", "testDescTable1.result");
+  }
+
+  @Test
+  public void testDescTableNamedWithSpace() throws Exception {
+    testDescTable("TEST DESC TABLE", "testDescTable2.result");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/tajo/blob/7fb0f25e/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable.result
----------------------------------------------------------------------
diff --git 
a/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable.result 
b/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable.result
deleted file mode 100644
index f065e6e..0000000
--- 
a/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable.result
+++ /dev/null
@@ -1,27 +0,0 @@
-OK
-
-table name: default.TEST_DESC_TABLE
-table uri: ${table.path}
-store type: TEXT
-number of rows: 0
-volume: 0 B
-Options: 
-       'text.delimiter'='|'
-
-schema: 
-col1   INT4
-col2   INT4
-
-
-
-table name: default.TEST_DESC_TABLE
-table uri: ${table.path}
-store type: TEXT
-number of rows: 0
-volume: 0 B
-Options: 
-       'text.delimiter'='|'
-
-schema: 
-col1   INT4
-col2   INT4
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/7fb0f25e/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable1.result
----------------------------------------------------------------------
diff --git 
a/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable1.result 
b/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable1.result
new file mode 100644
index 0000000..f065e6e
--- /dev/null
+++ 
b/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable1.result
@@ -0,0 +1,27 @@
+OK
+
+table name: default.TEST_DESC_TABLE
+table uri: ${table.path}
+store type: TEXT
+number of rows: 0
+volume: 0 B
+Options: 
+       'text.delimiter'='|'
+
+schema: 
+col1   INT4
+col2   INT4
+
+
+
+table name: default.TEST_DESC_TABLE
+table uri: ${table.path}
+store type: TEXT
+number of rows: 0
+volume: 0 B
+Options: 
+       'text.delimiter'='|'
+
+schema: 
+col1   INT4
+col2   INT4
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/7fb0f25e/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable2.result
----------------------------------------------------------------------
diff --git 
a/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable2.result 
b/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable2.result
new file mode 100644
index 0000000..8534299
--- /dev/null
+++ 
b/tajo-core-tests/src/test/resources/results/TestTajoCli/testDescTable2.result
@@ -0,0 +1,27 @@
+OK
+
+table name: default.TEST DESC TABLE
+table uri: ${table.path}
+store type: TEXT
+number of rows: 0
+volume: 0 B
+Options: 
+       'text.delimiter'='|'
+
+schema: 
+col1   INT4
+col2   INT4
+
+
+
+table name: default.TEST DESC TABLE
+table uri: ${table.path}
+store type: TEXT
+number of rows: 0
+volume: 0 B
+Options: 
+       'text.delimiter'='|'
+
+schema: 
+col1   INT4
+col2   INT4
\ No newline at end of file

Reply via email to