tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject git commit: TAJO-772: TajoDump cannot dump upper/lower mixed case database names.
Date Fri, 18 Apr 2014 07:51:32 GMT
Repository: tajo
Updated Branches:
  refs/heads/branch-0.8.0 99c5c33b9 -> c89d8d6b1


TAJO-772: TajoDump cannot dump upper/lower mixed case database names.


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

Branch: refs/heads/branch-0.8.0
Commit: c89d8d6b16f9938b19a30b834d730a61de7ccd98
Parents: 99c5c33
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Fri Apr 18 10:58:25 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Fri Apr 18 11:01:56 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++
 .../org/apache/tajo/catalog/DDLBuilder.java     |  4 +-
 .../java/org/apache/tajo/client/TajoDump.java   | 32 ++++++++------
 .../apache/tajo/engine/planner/LogicalPlan.java | 28 ++++++++++++-
 .../planner/logical/CreateDatabaseNode.java     |  4 +-
 .../engine/planner/logical/RelationNode.java    |  2 +
 .../tajo/engine/planner/logical/ScanNode.java   |  5 +++
 .../planner/logical/TableSubQueryNode.java      |  5 +++
 .../java/org/apache/tajo/QueryTestCaseBase.java | 35 +++++++++++++---
 .../apache/tajo/engine/query/TestDropTable.java |  5 +--
 .../tajo/engine/query/TestSelectQuery.java      | 22 ++++++++++
 .../org/apache/tajo/client/TestTajoDump.java    | 44 ++++++++++++++++++++
 .../queries/TestDropTable/drop_table_ddl.sql    |  2 +-
 .../resources/queries/TestNetTypes/testJoin.sql |  2 +-
 .../TestSelectQuery/testDatabaseRef1.sql        |  1 +
 .../TestSelectQuery/testDatabaseRef2.sql        |  1 +
 .../TestSelectQuery/testDatabaseRef3.sql        |  1 +
 .../results/TestNetTypes/testJoin.result        |  8 ++--
 .../TestSelectQuery/testDatabaseRef.result      |  7 ++++
 .../results/TestTajoDump/testDump1.result       | 17 ++++++++
 .../testBuildDDLQuotedTableName1.result         |  2 +-
 .../testBuildDDLQuotedTableName2.result         |  2 +-
 22 files changed, 197 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 0470e07..516665e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -325,6 +325,9 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
+    TAJO-772: TajoDump cannot dump upper/lower mixed case database names.
+    (hyunsik)
+
     TAJO-765: Incorrect Configuration Classpaths. (jinho)
 
     TAJO-563: INSERT OVERWRITE should not remove data before query success.

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
index d9cbcee..1b76f16 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java
@@ -29,7 +29,7 @@ public class DDLBuilder {
     StringBuilder sb = new StringBuilder();
 
     sb.append("--\n")
-      .append("-- Name: ").append(desc.getName()).append("; Type: TABLE;")
+      .append("-- Name: ").append(CatalogUtil.denormalizeIdentifier(desc.getName())).append(";
Type: TABLE;")
       .append(" Storage: ").append(desc.getMeta().getStoreType().name());
     sb.append("\n-- Path: ").append(desc.getPath());
     sb.append("\n--\n");
@@ -52,7 +52,7 @@ public class DDLBuilder {
     StringBuilder sb = new StringBuilder();
 
     sb.append("--\n")
-        .append("-- Name: ").append(desc.getName()).append("; Type: TABLE;")
+        .append("-- Name: ").append(CatalogUtil.denormalizeIdentifier(desc.getName())).append(";
Type: TABLE;")
         .append(" Storage: ").append(desc.getMeta().getStoreType().name());
     sb.append("\n-- Path: ").append(desc.getPath());
     sb.append("\n--\n");

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java
----------------------------------------------------------------------
diff --git a/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java b/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java
index 63dd35a..05a921e 100644
--- a/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java
+++ b/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java
@@ -33,6 +33,7 @@ import java.io.PrintWriter;
 import java.sql.SQLException;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.List;
@@ -109,21 +110,27 @@ public class TajoDump {
     }
 
     PrintWriter writer = new PrintWriter(System.out);
+    dump(client, userInfo, baseDatabaseName, isDumpingAllDatabases, writer);
 
-    printHeader(writer, userInfo);
+    System.exit(0);
+  }
+
+  public static void dump(TajoClient client, UserGroupInformation userInfo, String baseDatabaseName,
+                   boolean isDumpingAllDatabases, PrintWriter out) throws SQLException, ServiceException
{
+    printHeader(out, userInfo);
 
     if (isDumpingAllDatabases) {
-      for (String databaseName : client.getAllDatabaseNames()) {
-        dumpDatabase(client, databaseName, writer);
+      // sort database names in an ascending lexicographic order of the names.
+      List<String> sorted = new ArrayList<String>(client.getAllDatabaseNames());
+      Collections.sort(sorted);
+
+      for (String databaseName : sorted) {
+        dumpDatabase(client, databaseName, out);
       }
     } else {
-      dumpDatabase(client, baseDatabaseName, writer);
+      dumpDatabase(client, baseDatabaseName, out);
     }
-    client.close();
-
-    writer.flush();
-    writer.close();
-    System.exit(0);
+    out.flush();
   }
 
   private static void printHeader(PrintWriter writer, UserGroupInformation userInfo) {
@@ -140,10 +147,10 @@ public class TajoDump {
       throws SQLException, ServiceException {
     writer.write("\n");
     writer.write("--\n");
-    writer.write(String.format("-- Database name: %s%n", databaseName));
+    writer.write(String.format("-- Database name: %s%n", CatalogUtil.denormalizeIdentifier(databaseName)));
     writer.write("--\n");
     writer.write("\n");
-    writer.write(String.format("CREATE DATABASE IF NOT EXISTS %s;", databaseName));
+    writer.write(String.format("CREATE DATABASE IF NOT EXISTS %s;", CatalogUtil.denormalizeIdentifier(databaseName)));
     writer.write("\n");
 
     // returned list is immutable.
@@ -151,8 +158,7 @@ public class TajoDump {
     Collections.sort(tableNames);
     for (String tableName : tableNames) {
       try {
-        TableDesc table =
-            client.getTableDesc(CatalogUtil.denormalizeIdentifier(CatalogUtil.buildFQName(databaseName,tableName)));
+        TableDesc table = client.getTableDesc(CatalogUtil.buildFQName(databaseName, tableName));
         if (table.isExternal()) {
           writer.write(DDLBuilder.buildDDLForExternalTable(table));
         } else {

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/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 52dbde8..98fbf42 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
@@ -262,6 +262,26 @@ public class LogicalPlan {
     return found.getQualifiedName();
   }
 
+  public String resolveDatabase(QueryBlock block, String tableName) throws PlanningException
{
+    List<String> found = new ArrayList<String>();
+    for (RelationNode relation : block.getRelations()) {
+      // check alias name or table name
+      if (CatalogUtil.extractSimpleName(relation.getCanonicalName()).equals(tableName) ||
+          CatalogUtil.extractSimpleName(relation.getTableName()).equals(tableName)) {
+        // obtain the database name
+        found.add(CatalogUtil.extractQualifier(relation.getTableName()));
+      }
+    }
+
+    if (found.size() == 0) {
+      return null;
+    } else if (found.size() > 1) {
+      throw new PlanningException("Ambiguous table name \"" + tableName + "\"");
+    }
+
+    return found.get(0);
+  }
+
   /**
    * It resolves a column.
    */
@@ -277,8 +297,12 @@ public class LogicalPlan {
         qualifier = columnRef.getQualifier();
         canonicalName = columnRef.getCanonicalName();
       } else {
-        qualifier = CatalogUtil.buildFQName(currentDatabase, columnRef.getQualifier());
-        canonicalName = CatalogUtil.buildFQName(currentDatabase, columnRef.getCanonicalName());
+        String resolvedDatabaseName = resolveDatabase(block, columnRef.getQualifier());
+        if (resolvedDatabaseName == null) {
+          throw new NoSuchColumnException(columnRef.getQualifier());
+        }
+        qualifier = CatalogUtil.buildFQName(resolvedDatabaseName, columnRef.getQualifier());
+        canonicalName = CatalogUtil.buildFQName(qualifier, columnRef.getName());
       }
       qualifiedName = CatalogUtil.buildFQName(qualifier, columnRef.getName());
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/CreateDatabaseNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/CreateDatabaseNode.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/CreateDatabaseNode.java
index e0b2f0f..9dc73e2 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/CreateDatabaseNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/CreateDatabaseNode.java
@@ -19,6 +19,7 @@
 package org.apache.tajo.engine.planner.logical;
 
 import com.google.common.base.Objects;
+import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.engine.planner.PlanString;
 
 public class CreateDatabaseNode extends LogicalNode implements Cloneable {
@@ -70,7 +71,8 @@ public class CreateDatabaseNode extends LogicalNode implements Cloneable
{
 
   @Override
   public String toString() {
-    return "CREATE DATABASE " + (ifNotExists ? " IF NOT EXISTS " : "") + databaseName;
+    return "CREATE DATABASE " + (ifNotExists ? " IF NOT EXISTS " : "")
+        + CatalogUtil.denormalizeIdentifier(databaseName);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java
index 9e4575c..83c16cd 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java
@@ -39,6 +39,8 @@ public abstract class RelationNode extends LogicalNode {
 
   public abstract boolean hasAlias();
 
+  public abstract String getAlias();
+
   public abstract String getTableName();
 
   public abstract String getCanonicalName();

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
index 1488d8c..27782a2 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
@@ -79,6 +79,11 @@ public class ScanNode extends RelationNode implements Projectable, Cloneable
{
 	  return alias != null;
 	}
 
+  @Override
+  public String getAlias() {
+    return alias;
+  }
+
   public void setBroadcastTable(boolean broadcastTable) {
     this.broadcastTable = broadcastTable;
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
index 52f1027..4d0090b 100644
--- a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
+++ b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
@@ -51,6 +51,11 @@ public class TableSubQueryNode extends RelationNode implements Projectable
{
     return false;
   }
 
+  @Override
+  public String getAlias() {
+    return null;
+  }
+
   public String getTableName() {
     return tableName;
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/QueryTestCaseBase.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/QueryTestCaseBase.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/QueryTestCaseBase.java
index db40169..961184c 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/QueryTestCaseBase.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/QueryTestCaseBase.java
@@ -165,7 +165,7 @@ public class QueryTestCaseBase {
   @AfterClass
   public static void tearDownClass() throws ServiceException {
     for (String tableName : createdTableGlobalSet) {
-      client.updateQuery("DROP TABLE IF EXISTS " +tableName);
+      client.updateQuery("DROP TABLE IF EXISTS " + CatalogUtil.denormalizeIdentifier(tableName));
     }
     createdTableGlobalSet.clear();
 
@@ -182,7 +182,13 @@ public class QueryTestCaseBase {
   }
 
   public QueryTestCaseBase() {
-    this.currentDatabase = CatalogUtil.normalizeIdentifier(getClass().getSimpleName());
+    // hive 0.12 does not support quoted identifier.
+    // So, we use lower case database names when Tajo uses HCatalogStore.
+    if (testingCluster.isHCatalogStoreRunning()) {
+      this.currentDatabase = getClass().getSimpleName().toLowerCase();
+    } else {
+      this.currentDatabase = getClass().getSimpleName();
+    }
     init();
   }
 
@@ -200,7 +206,7 @@ public class QueryTestCaseBase {
     try {
       // if the current database is "default", we don't need create it because it is already
prepated at startup time.
       if (!currentDatabase.equals(TajoConstants.DEFAULT_DATABASE_NAME)) {
-        client.updateQuery("CREATE DATABASE IF NOT EXISTS " + currentDatabase);
+        client.updateQuery("CREATE DATABASE IF NOT EXISTS " + CatalogUtil.denormalizeIdentifier(currentDatabase));
       }
       client.selectDatabase(currentDatabase);
     } catch (ServiceException e) {
@@ -285,12 +291,29 @@ public class QueryTestCaseBase {
     Path resultFile = getResultFile(resultFileName);
     assertTrue(resultFile.toString() + " existence check", fs.exists(resultFile));
     try {
-      verifyResult(message, result, resultFile);
+      verifyResultText(message, result, resultFile);
     } catch (SQLException e) {
       throw new IOException(e);
     }
   }
 
+  public final void assertStrings(String actual) throws IOException {
+    assertStrings(actual, name.getMethodName() + ".result");
+  }
+
+  public final void assertStrings(String actual, String resultFileName) throws IOException
{
+    assertStrings("Result Verification", actual, resultFileName);
+  }
+
+  public final void assertStrings(String message, String actual, String resultFileName) throws
IOException {
+    FileSystem fs = currentQueryPath.getFileSystem(testBase.getTestingCluster().getConfiguration());
+    Path resultFile = getResultFile(resultFileName);
+    assertTrue(resultFile.toString() + " existence check", fs.exists(resultFile));
+
+    String expectedResult = FileUtil.readTextFile(new File(resultFile.toUri()));
+    assertEquals(message, expectedResult, actual);
+  }
+
   /**
    * Release all resources
    *
@@ -381,7 +404,7 @@ public class QueryTestCaseBase {
     return sb.toString();
   }
 
-  private void verifyResult(String message, ResultSet res, Path resultFile) throws SQLException,
IOException {
+  private void verifyResultText(String message, ResultSet res, Path resultFile) throws SQLException,
IOException {
     String actualResult = resultSetToString(res);
     String expectedResult = FileUtil.readTextFile(new File(resultFile.toUri()));
     assertEquals(message, expectedResult.trim(), actualResult.trim());
@@ -460,7 +483,7 @@ public class QueryTestCaseBase {
 
         assertTrue("table '" + createdTableName + "' creation check", client.existTable(createdTableName));
         if (isLocalTable) {
-          createdTableGlobalSet.add(CatalogUtil.denormalizeIdentifier(createdTableName));
+          createdTableGlobalSet.add(createdTableName);
           createdTableNames.add(tableName);
         }
       } else if (expr.getType() == OpType.DropTable) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestDropTable.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestDropTable.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestDropTable.java
index e362eef..0020156 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestDropTable.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestDropTable.java
@@ -30,10 +30,9 @@ public class TestDropTable extends QueryTestCaseBase {
 
   @Test
   public final void testDropManagedTable() throws Exception {
-    List<String> createdNames = executeDDL("table1_ddl.sql", "table1.tbl", "ABC");
+    List<String> createdNames = executeDDL("table1_ddl.sql", "table1.tbl", "abc");
     assertTableExists(createdNames.get(0));
     executeDDL("drop_table_ddl.sql", null);
-    assertTableNotExists("ABC");
+    assertTableNotExists("abc");
   }
-
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
index 96f3bbe..05c510b 100644
--- a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
+++ b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
@@ -278,4 +278,26 @@ public class TestSelectQuery extends QueryTestCaseBase {
     assertResultSet(res);
     cleanupQuery(res);
   }
+
+  @Test
+  public final void testDatabaseRef() throws Exception {
+    if (!testingCluster.isHCatalogStoreRunning()) {
+      executeString("CREATE DATABASE \"TestSelectQuery\"").close();
+      executeString("CREATE TABLE \"TestSelectQuery\".\"LineItem\" AS SELECT * FROM default.lineitem"
).close();
+
+      ResultSet res = executeFile("testDatabaseRef1.sql");
+      assertResultSet(res, "testDatabaseRef.result");
+      cleanupQuery(res);
+
+      res = executeFile("testDatabaseRef2.sql");
+      assertResultSet(res, "testDatabaseRef.result");
+      cleanupQuery(res);
+
+      res = executeFile("testDatabaseRef3.sql");
+      assertResultSet(res, "testDatabaseRef.result");
+      cleanupQuery(res);
+
+      executeString("DROP DATABASE \"TestSelectQuery\"").close();
+    }
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/org/apache/tajo/client/TestTajoDump.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/org/apache/tajo/client/TestTajoDump.java
b/tajo-core/tajo-core-backend/src/test/resources/org/apache/tajo/client/TestTajoDump.java
new file mode 100644
index 0000000..f98a9f5
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/org/apache/tajo/client/TestTajoDump.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.client;
+
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.tajo.QueryTestCaseBase;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+public class TestTajoDump extends QueryTestCaseBase {
+
+  @Test
+  public void testDump1() throws Exception {
+    executeString("CREATE TABLE \"" +getCurrentDatabase() +
+        "\".\"TableName1\" (\"Age\" int, \"FirstName\" TEXT, lastname TEXT)");
+
+    UserGroupInformation userInfo = UserGroupInformation.getCurrentUser();
+    ByteArrayOutputStream bos = new ByteArrayOutputStream();
+    PrintWriter printWriter = new PrintWriter(bos);
+    TajoDump.dump(client, userInfo, getCurrentDatabase(), false, printWriter);
+    printWriter.flush();
+    printWriter.close();
+    assertStrings(new String(bos.toByteArray()));
+    bos.close();
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/queries/TestDropTable/drop_table_ddl.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestDropTable/drop_table_ddl.sql
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestDropTable/drop_table_ddl.sql
index c770b43..c58f459 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/queries/TestDropTable/drop_table_ddl.sql
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestDropTable/drop_table_ddl.sql
@@ -1 +1 @@
-DROP TABLE ABC PURGE
\ No newline at end of file
+DROP TABLE abc PURGE;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/testJoin.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/testJoin.sql
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/testJoin.sql
index efb9db3..ec4f8e6 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/testJoin.sql
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/testJoin.sql
@@ -1 +1 @@
-select * from table1 as t1, table2 as t2 where t1.addr = t2.addr order by t2.name;
\ No newline at end of file
+select t1.*,t2.* from table1 as t1, table2 as t2 where t1.addr = t2.addr order by t2.name;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef1.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef1.sql
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef1.sql
new file mode 100644
index 0000000..a483758
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef1.sql
@@ -0,0 +1 @@
+SELECT L_ORDERKEY FROM "TestSelectQuery"."LineItem";
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef2.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef2.sql
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef2.sql
new file mode 100644
index 0000000..6abc3f9
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef2.sql
@@ -0,0 +1 @@
+SELECT "LineItem".L_ORDERKEY FROM "TestSelectQuery"."LineItem";
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef3.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef3.sql
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef3.sql
new file mode 100644
index 0000000..3fded5f
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestSelectQuery/testDatabaseRef3.sql
@@ -0,0 +1 @@
+SELECT "TestSelectQuery"."LineItem".L_ORDERKEY FROM "TestSelectQuery"."LineItem";
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/results/TestNetTypes/testJoin.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestNetTypes/testJoin.result
b/tajo-core/tajo-core-backend/src/test/resources/results/TestNetTypes/testJoin.result
index b5817f8..ea979ac 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/results/TestNetTypes/testJoin.result
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestNetTypes/testJoin.result
@@ -1,6 +1,6 @@
 id,name,score,type,addr,id,name,score,type,addr
 -------------------------------
-0,,20.0,d,127.0.0.1,1,ooo,1.1,a,127.0.0.1
-1,,0.0,a,127.0.0.8,3,qqq,3.4,c,127.0.0.8
-2,,0.0,b,127.0.0.8,3,qqq,3.4,c,127.0.0.8
-0,,20.0,d,127.0.0.1,4,rrr,4.5,d,127.0.0.1
\ No newline at end of file
+1,ooo,1.1,a,127.0.0.1,0,,20.0,d,127.0.0.1
+3,qqq,3.4,c,127.0.0.8,1,,0.0,a,127.0.0.8
+3,qqq,3.4,c,127.0.0.8,2,,0.0,b,127.0.0.8
+4,rrr,4.5,d,127.0.0.1,0,,20.0,d,127.0.0.1
\ No newline at end of file

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

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoDump/testDump1.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoDump/testDump1.result
b/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoDump/testDump1.result
new file mode 100644
index 0000000..bdf31fa
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoDump/testDump1.result
@@ -0,0 +1,17 @@
+--
+-- Tajo database dump
+--
+-- Dump user: hyunsik
+-- Dump date: 04/17/2014 13:33:45
+--
+
+
+--
+-- Database name: "TestTajoDump"
+--
+
+CREATE DATABASE IF NOT EXISTS "TestTajoDump";
+--
+-- Name: TestTajoDump.TableName1; Type: TABLE; Storage: CSV
+--
+CREATE TABLE "TestTajoDump"."TableName1" ("Age" INT4, "FirstName" TEXT, lastname TEXT) USING
CSV WITH ('csvfile.delimiter'='|');
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName1.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName1.result
b/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName1.result
index ee9845e..3ff5134 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName1.result
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName1.result
@@ -1,5 +1,5 @@
 --
--- Name: db1.TABLE2; Type: TABLE; Storage: CSV
+-- Name: db1."TABLE2"; Type: TABLE; Storage: CSV
 -- Path: /table1
 --
 CREATE EXTERNAL TABLE db1."TABLE2" (name BLOB, addr TEXT, "FirstName" TEXT, "LastName" TEXT,
"with" TEXT) USING CSV WITH ('compression.codec'='org.apache.hadoop.io.compress.GzipCodec',
'csvfile.delimiter'='|') PARTITION BY COLUMN("BirthYear" INT4) LOCATION '/table1';
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/c89d8d6b/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result
b/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result
index 40e4ff1..da391cb 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result
@@ -1,5 +1,5 @@
 --
--- Name: db1.TABLE1; Type: TABLE; Storage: CSV
+-- Name: db1."TABLE1"; Type: TABLE; Storage: CSV
 -- Path: /table1
 --
 CREATE TABLE db1."TABLE1" (name BLOB, addr TEXT, "FirstName" TEXT, "LastName" TEXT, "with"
TEXT) USING CSV WITH ('compression.codec'='org.apache.hadoop.io.compress.GzipCodec', 'csvfile.delimiter'='|')
PARTITION BY COLUMN("BirthYear" INT4);
\ No newline at end of file


Mime
View raw message