tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [4/7] tajo git commit: TAJO-1495: Clean up CatalogStore. (jaehwa)
Date Thu, 02 Apr 2015 11:05:57 GMT
TAJO-1495: Clean up CatalogStore. (jaehwa)

Closes #491


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

Branch: refs/heads/index_support
Commit: bda2d6236df1db352206e831b0da93b31de701bf
Parents: d6735fb
Author: JaeHwa Jung <blrunner@apache.org>
Authored: Thu Apr 2 18:08:52 2015 +0900
Committer: JaeHwa Jung <blrunner@apache.org>
Committed: Thu Apr 2 18:08:52 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |   2 +
 .../store/AbstractMySQLMariaDBStore.java        | 311 -------------------
 .../apache/tajo/catalog/store/MariaDBStore.java |  26 +-
 .../apache/tajo/catalog/store/MySQLStore.java   |  29 +-
 .../src/main/resources/schemas/common/meta.sql  |   1 -
 .../src/main/resources/schemas/derby/derby.xml  |  14 +-
 .../main/resources/schemas/mariadb/columns.sql  |  10 -
 .../resources/schemas/mariadb/databases.sql     |   7 -
 .../main/resources/schemas/mariadb/indexes.sql  |  16 -
 .../main/resources/schemas/mariadb/mariadb.xml  | 161 ++++++++++
 .../schemas/mariadb/partition_keys.sql          |   6 -
 .../schemas/mariadb/partition_methods.sql       |   7 -
 .../resources/schemas/mariadb/partitions.sql    |   7 -
 .../main/resources/schemas/mariadb/stats.sql    |   6 -
 .../schemas/mariadb/table_properties.sql        |   7 -
 .../main/resources/schemas/mariadb/tables.sql   |  11 -
 .../resources/schemas/mariadb/tablespaces.sql   |   7 -
 .../main/resources/schemas/mysql/columns.sql    |  10 -
 .../main/resources/schemas/mysql/databases.sql  |   7 -
 .../main/resources/schemas/mysql/indexes.sql    |  16 -
 .../src/main/resources/schemas/mysql/mysql.xml  | 162 ++++++++++
 .../resources/schemas/mysql/partition_keys.sql  |   6 -
 .../schemas/mysql/partition_methods.sql         |   7 -
 .../main/resources/schemas/mysql/partitions.sql |   7 -
 .../src/main/resources/schemas/mysql/stats.sql  |   6 -
 .../schemas/mysql/table_properties.sql          |   7 -
 .../src/main/resources/schemas/mysql/tables.sql |  11 -
 .../resources/schemas/mysql/tablespaces.sql     |   7 -
 .../main/resources/schemas/oracle/oracle.xml    |  19 +-
 .../resources/schemas/postgresql/postgresql.xml |  26 +-
 30 files changed, 384 insertions(+), 535 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 71c5159..6eca36d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,8 @@ Release 0.11.0 - unreleased
     (jihun)
 
   IMPROVEMENT
+
+    TAJO-1495: Clean up CatalogStore. (jaehwa)
    
     TAJO-1460: Apply TAJO-1407 to ExternalSortExec. (Contributed by navis, 
     Committed by hyoungjun)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractMySQLMariaDBStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractMySQLMariaDBStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractMySQLMariaDBStore.java
deleted file mode 100644
index 6f1b765..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractMySQLMariaDBStore.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/**
- * 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.catalog.store;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.catalog.exception.CatalogException;
-import org.apache.tajo.exception.InternalException;
-
-import java.sql.*;
-import java.util.HashMap;
-import java.util.Map;
-
-public abstract class AbstractMySQLMariaDBStore extends AbstractDBStore  {
-  protected String getCatalogDriverName(){
-    throw new CatalogException("you can't use this directly.");
-  }
-
-  public AbstractMySQLMariaDBStore(final Configuration conf) throws InternalException {
-    super(conf);
-  }
-
-  @Override
-  public int getDriverVersion() {
-    throw new CatalogException("you can't use this directly.");
-  }
-
-  protected Connection createConnection(Configuration conf) throws SQLException {
-    Connection con = DriverManager.getConnection(getCatalogUri(), this.connectionId,
-        this.connectionPassword);
-    //TODO con.setAutoCommit(false);
-    return con;
-  }
-
-  @Override
-  protected boolean isConnValid(int timeout) throws CatalogException {
-    boolean isValid = false;
-
-    try {
-      isValid = super.isConnValid(timeout);
-    } catch (NullPointerException e) {
-      LOG.info("Conn abortion when checking isValid; retrieve false to create another Conn.");
-    }
-    return isValid;
-  }
-
-  @Override
-  public String readSchemaFile(String filename) throws CatalogException {
-      return super.readSchemaFile(filename);
-  }
-
-  // TODO - DDL and index statements should be renamed
-  @Override
-  protected void createBaseTable() throws CatalogException {
-    Statement stmt = null;
-    Connection conn = null;
-
-    try {
-      conn = getConnection();
-      stmt = conn.createStatement();
-
-
-      // META
-      if (!baseTableMaps.get(TB_META)) {
-        String sql = super.readSchemaFile("common/meta.sql");
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql.toString());
-        }
-
-        stmt.executeUpdate(sql.toString());
-        LOG.info("Table '" + TB_META + " is created.");
-        baseTableMaps.put(TB_META, true);
-      }
-
-      // TABLE SPACES
-      if (!baseTableMaps.get(TB_SPACES)) {
-        String sql = readSchemaFile("tablespaces.sql");
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql);
-        }
-
-        stmt.executeUpdate(sql);
-
-        LOG.info("Table '" + TB_SPACES + "' is created.");
-        baseTableMaps.put(TB_SPACES, true);
-      }
-
-      // DATABASES
-      if (!baseTableMaps.get(TB_DATABASES)) {
-        String sql = readSchemaFile("databases.sql");
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql);
-        }
-        LOG.info("Table '" + TB_DATABASES + "' is created.");
-        baseTableMaps.put(TB_DATABASES, true);
-        stmt.executeUpdate(sql);
-      }
-
-      // TABLES
-      if (!baseTableMaps.get(TB_TABLES)) {
-        String sql = readSchemaFile("tables.sql");
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql);
-        }
-        stmt.executeUpdate(sql);
-        LOG.info("Table '" + TB_TABLES + "' is created.");
-        baseTableMaps.put(TB_TABLES, true);
-      }
-
-      // COLUMNS
-      if (!baseTableMaps.get(TB_COLUMNS)) {
-        String sql = readSchemaFile("columns.sql");
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql);
-        }
-
-        stmt.executeUpdate(sql.toString());
-        LOG.info("Table '" + TB_COLUMNS + " is created.");
-        baseTableMaps.put(TB_COLUMNS, true);
-      }
-
-      // OPTIONS
-      if (!baseTableMaps.get(TB_OPTIONS)) {
-        String sql = readSchemaFile("table_properties.sql");
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql.toString());
-        }
-
-        stmt.executeUpdate(sql.toString());
-        LOG.info("Table '" + TB_OPTIONS + " is created.");
-        baseTableMaps.put(TB_OPTIONS, true);
-      }
-
-      // INDEXES
-      if (!baseTableMaps.get(TB_INDEXES)) {
-        String sql = readSchemaFile("indexes.sql");
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql.toString());
-        }
-
-        stmt.executeUpdate(sql.toString());
-        LOG.info("Table '" + TB_INDEXES + "' is created.");
-        baseTableMaps.put(TB_INDEXES, true);
-      }
-
-      if (!baseTableMaps.get(TB_STATISTICS)) {
-        String sql = readSchemaFile("stats.sql");
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql.toString());
-        }
-
-        stmt.executeUpdate(sql.toString());
-        LOG.info("Table '" + TB_STATISTICS + "' is created.");
-        baseTableMaps.put(TB_STATISTICS, true);
-      }
-
-      // PARTITION_METHODS
-      if (!baseTableMaps.get(TB_PARTITION_METHODS)) {
-        String sql = readSchemaFile("partition_methods.sql");
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql);
-        }
-
-        stmt.executeUpdate(sql);
-        LOG.info("Table '" + TB_PARTITION_METHODS + "' is created.");
-        baseTableMaps.put(TB_PARTITION_METHODS, true);
-      }
-
-      // PARTITIONS
-      if (!baseTableMaps.get(TB_PARTTIONS)) {
-        String sql = readSchemaFile("partitions.sql");
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql.toString());
-        }
-
-        stmt.executeUpdate(sql.toString());
-        LOG.info("Table '" + TB_PARTTIONS + "' is created.");
-        baseTableMaps.put(TB_PARTTIONS, true);
-      }
-
-      // PARTITION_KEYS
-      if (!baseTableMaps.get(TB_PARTTION_KEYS)) {
-        String sql = readSchemaFile("partition_keys.sql");
-
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(sql.toString());
-        }
-
-        stmt.executeUpdate(sql.toString());
-        LOG.info("Table '" + TB_PARTTION_KEYS + "' is created.");
-        baseTableMaps.put(TB_PARTTION_KEYS, true);
-      }
-
-      insertSchemaVersion();
-
-    } catch (SQLException se) {
-      throw new CatalogException("failed to create base tables for MySQL catalog store", se);
-    } finally {
-      CatalogUtil.closeQuietly(stmt);
-    }
-  }
-
-  @Override
-  protected void dropBaseTable() throws CatalogException {
-    Connection conn = null;
-    Statement stmt = null;
-    Map<String, Boolean> droppedTable = new HashMap<String, Boolean>();
-
-    try {
-      conn = getConnection();
-      stmt = conn.createStatement();
-      StringBuilder sql = new StringBuilder();
-
-      for(Map.Entry<String, Boolean> entry : baseTableMaps.entrySet()) {
-        if(entry.getValue() && !entry.getKey().equals(TB_TABLES)) {
-          sql.delete(0, sql.length());
-          sql.append("DROP TABLE ").append(entry.getKey());
-          stmt.addBatch(sql.toString());
-          droppedTable.put(entry.getKey(), true);
-        }
-      }
-      if(baseTableMaps.get(TB_TABLES)) {
-        sql.delete(0, sql.length());
-        sql.append("DROP TABLE ").append(TB_TABLES);
-        stmt.addBatch(sql.toString());
-        droppedTable.put(TB_TABLES, true);
-      }
-      stmt.executeBatch();
-
-      for(String tableName : droppedTable.keySet()) {
-        LOG.info("Table '" + tableName + "' is dropped");
-      }
-    } catch (SQLException se) {
-      throw new CatalogException(se);
-    } finally {
-      CatalogUtil.closeQuietly(stmt);
-    }
-  }
-
-  @Override
-  protected boolean isInitialized() throws CatalogException {
-    Connection conn;
-    ResultSet res = null;
-
-    try {
-      conn = getConnection();
-      res = conn.getMetaData().getTables(null, null, null,
-          new String[]{"TABLE"});
-
-      baseTableMaps.put(TB_META, false);
-      baseTableMaps.put(TB_SPACES, false);
-      baseTableMaps.put(TB_DATABASES, false);
-      baseTableMaps.put(TB_TABLES, false);
-      baseTableMaps.put(TB_COLUMNS, false);
-      baseTableMaps.put(TB_OPTIONS, false);
-      baseTableMaps.put(TB_STATISTICS, false);
-      baseTableMaps.put(TB_INDEXES, false);
-      baseTableMaps.put(TB_PARTITION_METHODS, false);
-      baseTableMaps.put(TB_PARTTIONS, false);
-      baseTableMaps.put(TB_PARTTION_KEYS, false);
-
-      if (res.wasNull())
-        return false;
-
-      while (res.next()) {
-        // if my.cnf has lower_case_table_names = 1,
-        // TABLE_NAME returns lower case even it created by upper case.
-        baseTableMaps.put(res.getString("TABLE_NAME").toUpperCase(), true);
-      }
-
-      for(Map.Entry<String, Boolean> entry : baseTableMaps.entrySet()) {
-        if (!entry.getValue()) {
-          return false;
-        }
-      }
-
-    } catch(SQLException se) {
-      throw new CatalogException(se);
-    } finally {
-      CatalogUtil.closeQuietly(res);
-    }
-
-    return  true;
-  }
-}

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MariaDBStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MariaDBStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MariaDBStore.java
index 0159b31..cb661ac 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MariaDBStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MariaDBStore.java
@@ -25,29 +25,33 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.tajo.catalog.exception.CatalogException;
 import org.apache.tajo.exception.InternalException;
 
-public class MariaDBStore extends AbstractMySQLMariaDBStore {
-  /** 3 - 2015-03-12: Nested Schema (TAJO-1329) */
-  /** 2 - First versioning */
-  private static final int MARIADB_CATALOG_STORE_VERSION = 3;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
 
+public class MariaDBStore extends AbstractDBStore {
   private static final String CATALOG_DRIVER = "org.mariadb.jdbc.Driver";
 
+  public MariaDBStore(Configuration conf) throws InternalException {
+    super(conf);
+  }
+
   @Override
-  protected String getCatalogDriverName(){
+  protected String getCatalogDriverName() {
     return CATALOG_DRIVER;
   }
 
-  public MariaDBStore(final Configuration conf) throws InternalException {
-    super(conf);
+  @Override
+  protected String getCatalogSchemaPath() {
+    return "schemas/mariadb";
   }
 
   @Override
-  public int getDriverVersion() {
-    return MARIADB_CATALOG_STORE_VERSION;
+  protected Connection createConnection(Configuration conf) throws SQLException {
+    return DriverManager.getConnection(getCatalogUri(), this.connectionId, this.connectionPassword);
   }
 
   @Override
-  public String readSchemaFile(String filename) throws CatalogException {
-    return super.readSchemaFile("mariadb/" + filename);
+  protected void createDatabaseDependants() throws CatalogException {
   }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java
index f7f1b1b..d6e902a 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java
+++ b/tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/MySQLStore.java
@@ -25,30 +25,33 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.tajo.catalog.exception.CatalogException;
 import org.apache.tajo.exception.InternalException;
 
-public class MySQLStore extends AbstractMySQLMariaDBStore  {
-
-  /** 3 - 2015-03-12: Nested Schema (TAJO-1329) */
-  /** 2 - 2014-06-09: First versioning */
-  /** 1-  Before 2013-03-20 */
-  private static final int MYSQL_CATALOG_STORE_VERSION = 3;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
 
+public class MySQLStore extends AbstractDBStore {
   private static final String CATALOG_DRIVER = "com.mysql.jdbc.Driver";
+
+  public MySQLStore(Configuration conf) throws InternalException {
+    super(conf);
+  }
+
   @Override
-  protected String getCatalogDriverName(){
+  protected String getCatalogDriverName() {
     return CATALOG_DRIVER;
   }
 
-  public MySQLStore(final Configuration conf) throws InternalException {
-    super(conf);
+  @Override
+  protected String getCatalogSchemaPath() {
+    return "schemas/mysql";
   }
 
   @Override
-  public int getDriverVersion() {
-    return MYSQL_CATALOG_STORE_VERSION;
+  protected Connection createConnection(Configuration conf) throws SQLException {
+    return DriverManager.getConnection(getCatalogUri(), this.connectionId, this.connectionPassword);
   }
 
   @Override
-  public String readSchemaFile(String filename) throws CatalogException {
-    return super.readSchemaFile("mysql/" + filename);
+  protected void createDatabaseDependants() throws CatalogException {
   }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/common/meta.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/common/meta.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/common/meta.sql
deleted file mode 100644
index 066c5f8..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/common/meta.sql
+++ /dev/null
@@ -1 +0,0 @@
-CREATE TABLE META (VERSION INT NOT NULL)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/derby/derby.xml
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/derby/derby.xml b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/derby/derby.xml
index a239e68..a4ff00f 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/derby/derby.xml
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/derby/derby.xml
@@ -17,12 +17,14 @@
   limitations under the License.
   -->
 <tns:store xmlns:tns="http://tajo.apache.org/catalogstore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
-
-  <!-- Version History -->
-  <!-- 3 - 2015-03-12: Nested Schema (TAJO-1329) -->
-  <!-- 2 - First versioning -->
-
-	<tns:base version="3">
+  <!--
+      Catalog base version history
+      * 4 - 2015-03-27: Partition Schema (TAJO-1284)
+      * 3 - 2015-03-12: Nested Schema (TAJO-1329)
+      * 2 - 2014-06-09: First versioning
+      * 1-  Before 2013-03-20
+    -->
+	<tns:base version="4">
 		<tns:objects>
 			<tns:Object order="0" type="table" name="META">
 				<tns:sql><![CDATA[CREATE TABLE META (VERSION INT NOT NULL)]]></tns:sql>

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/columns.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/columns.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/columns.sql
deleted file mode 100644
index 5b8ed26..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/columns.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-CREATE TABLE COLUMNS (
-  TID INT NOT NULL,
-  COLUMN_NAME VARCHAR(255) BINARY NOT NULL,
-  ORDINAL_POSITION INT NOT NULL,
-  NESTED_FIELD_NUM INT NOT NULL,
-  DATA_TYPE CHAR(16),
-  TYPE_LENGTH INTEGER,
-  PRIMARY KEY (TID, ORDINAL_POSITION),
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/databases.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/databases.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/databases.sql
deleted file mode 100644
index 2f351cf..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/databases.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE DATABASES_ (
-  DB_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  DB_NAME VARCHAR(128) BINARY NOT NULL UNIQUE,
-  SPACE_ID INT NOT NULL,
-  FOREIGN KEY (SPACE_ID) REFERENCES TABLESPACES (SPACE_ID),
-  UNIQUE INDEX IDX_NAME (DB_NAME)
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/indexes.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/indexes.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/indexes.sql
deleted file mode 100644
index f58b17c..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/indexes.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-CREATE TABLE INDEXES (
-  DB_ID INT NOT NULL,
-  TID INT NOT NULL,
-  INDEX_NAME VARCHAR(128) BINARY NOT NULL,
-  COLUMN_NAME VARCHAR(128) BINARY NOT NULL,
-  DATA_TYPE VARCHAR(128) NOT NULL,
-  INDEX_TYPE CHAR(32) NOT NULL,
-  IS_UNIQUE BOOLEAN NOT NULL,
-  IS_CLUSTERED BOOLEAN NOT NULL,
-  IS_ASCENDING BOOLEAN NOT NULL,
-  PRIMARY KEY (DB_ID, INDEX_NAME),
-  FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID) ON DELETE CASCADE,
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE,
-  UNIQUE INDEX IDX_DB_ID_NAME (DB_ID, INDEX_NAME),
-  INDEX IDX_TID_COLUMN_NAME (TID, COLUMN_NAME)
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/mariadb.xml
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/mariadb.xml b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/mariadb.xml
new file mode 100644
index 0000000..79ccd0a
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/mariadb.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<tns:store xmlns:tns="http://tajo.apache.org/catalogstore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
+  <!--
+      Catalog base version history
+      * 4 - 2015-03-27: Partition Schema (TAJO-1284)
+      * 3 - 2015-03-12: Nested Schema (TAJO-1329)
+      * 2 - 2014-06-09: First versioning
+      * 1-  Before 2013-03-20
+    -->
+  <tns:base version="4">
+    <tns:objects>
+      <tns:Object order="0" type="table" name="META">
+        <tns:sql><![CDATA[CREATE TABLE META (VERSION INT NOT NULL)]]></tns:sql>
+      </tns:Object>
+      <tns:Object order="1" type="table" name="TABLESPACES">
+        <tns:sql><![CDATA[
+        CREATE TABLE TABLESPACES (
+          SPACE_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+          SPACE_NAME VARCHAR(128) BINARY NOT NULL UNIQUE,
+          SPACE_HANDLER VARCHAR (1024) DEFAULT 'HDFS',
+          SPACE_URI VARCHAR (4096) BINARY NOT NULL,
+          UNIQUE INDEX IDX_NAME (SPACE_NAME)
+				)]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="2" type="table" name="DATABASES_">
+        <tns:sql><![CDATA[
+        CREATE TABLE DATABASES_ (
+          DB_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+          DB_NAME VARCHAR(128) BINARY NOT NULL UNIQUE,
+          SPACE_ID INT NOT NULL,
+          FOREIGN KEY (SPACE_ID) REFERENCES TABLESPACES (SPACE_ID),
+          UNIQUE INDEX IDX_NAME (DB_NAME)
+				)]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="3" type="table" name="TABLES">
+        <tns:sql><![CDATA[
+        CREATE TABLE TABLES (
+          TID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+          DB_ID INT NOT NULL,
+          TABLE_NAME VARCHAR(128) BINARY NOT NULL,
+          TABLE_TYPE VARCHAR(128) NOT NULL,
+          PATH VARCHAR(4096) BINARY,
+          STORE_TYPE CHAR(16),
+          FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID),
+          INDEX IDX_DB_ID (DB_ID),
+          UNIQUE INDEX IDX_TABLE_ID (DB_ID, TABLE_NAME)
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="4" type="table" name="COLUMNS">
+        <tns:sql><![CDATA[
+        CREATE TABLE COLUMNS (
+          TID INT NOT NULL,
+          COLUMN_NAME VARCHAR(255) BINARY NOT NULL,
+          ORDINAL_POSITION INT NOT NULL,
+          NESTED_FIELD_NUM INT NOT NULL,
+          DATA_TYPE CHAR(16),
+          TYPE_LENGTH INTEGER,
+          PRIMARY KEY (TID, ORDINAL_POSITION),
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="5" type="table" name="OPTIONS">
+        <tns:sql><![CDATA[
+        CREATE TABLE OPTIONS (
+          TID INT NOT NULL,
+          KEY_ VARCHAR(255) BINARY NOT NULL,
+          VALUE_ VARCHAR(4000) NOT NULL,
+          PRIMARY KEY (TID, KEY_),
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="6" type="table" name="INDEXES">
+        <tns:sql><![CDATA[
+        CREATE TABLE INDEXES (
+          DB_ID INT NOT NULL,
+          TID INT NOT NULL,
+          INDEX_NAME VARCHAR(128) BINARY NOT NULL,
+          COLUMN_NAME VARCHAR(128) BINARY NOT NULL,
+          DATA_TYPE VARCHAR(128) NOT NULL,
+          INDEX_TYPE CHAR(32) NOT NULL,
+          IS_UNIQUE BOOLEAN NOT NULL,
+          IS_CLUSTERED BOOLEAN NOT NULL,
+          IS_ASCENDING BOOLEAN NOT NULL,
+          PRIMARY KEY (DB_ID, INDEX_NAME),
+          FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID) ON DELETE CASCADE,
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE,
+          UNIQUE INDEX IDX_DB_ID_NAME (DB_ID, INDEX_NAME),
+          INDEX IDX_TID_COLUMN_NAME (TID, COLUMN_NAME)
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="7" type="table" name="STATS">
+        <tns:sql><![CDATA[
+        CREATE TABLE STATS (
+          TID INT NOT NULL PRIMARY KEY,
+          NUM_ROWS BIGINT,
+          NUM_BYTES BIGINT,
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="8" type="table" name="PARTITION_METHODS">
+        <tns:sql><![CDATA[
+        CREATE TABLE PARTITION_METHODS (
+          TID INT NOT NULL PRIMARY KEY,
+          PARTITION_TYPE VARCHAR(10) NOT NULL,
+          EXPRESSION VARCHAR(1024) NOT NULL,
+          EXPRESSION_SCHEMA VARCHAR(1024) NOT NULL,
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="9" type="table" name="PARTITIONS">
+        <tns:sql><![CDATA[
+        CREATE TABLE PARTITIONS (
+          PARTITION_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+          TID INT NOT NULL,
+          PARTITION_NAME VARCHAR(255) BINARY,
+          PATH VARCHAR(4096) BINARY,
+          CONSTRAINT CONST_PARTITION_UNIQUE UNIQUE (PARTITION_NAME),
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="10" type="table" name="PARTITION_KEYS">
+        <tns:sql><![CDATA[
+        CREATE TABLE PARTITION_KEYS (
+          PARTITION_ID INT NOT NULL,
+          COLUMN_NAME VARCHAR(255) BINARY NOT NULL,
+          PARTITION_VALUE VARCHAR(255) BINARY NOT NULL,
+          UNIQUE INDEX PARTITION_KEYS_IDX (PARTITION_ID, COLUMN_NAME, PARTITION_VALUE),
+          FOREIGN KEY (PARTITION_ID) REFERENCES PARTITIONS (PARTITION_ID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+    </tns:objects>
+  </tns:base>
+
+</tns:store>

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partition_keys.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partition_keys.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partition_keys.sql
deleted file mode 100644
index 6f2f238..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partition_keys.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE PARTITION_KEYS (
-  PARTITION_ID INT NOT NULL,
-  COLUMN_NAME VARCHAR(255) BINARY NOT NULL,
-  PARTITION_VALUE VARCHAR(255) NOT NULL,
-  UNIQUE INDEX PARTITION_KEYS_IDX (PARTITION_ID, COLUMN_NAME, PARTITION_VALUE),
-  FOREIGN KEY (PARTITION_ID) REFERENCES PARTITIONS (PARTITION_ID) ON DELETE CASCADE)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partition_methods.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partition_methods.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partition_methods.sql
deleted file mode 100644
index 060c4c8..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partition_methods.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE PARTITION_METHODS (
-  TID INT NOT NULL PRIMARY KEY,
-  PARTITION_TYPE VARCHAR(10) NOT NULL,
-  EXPRESSION VARCHAR(1024) NOT NULL,
-  EXPRESSION_SCHEMA VARCHAR(1024) NOT NULL,
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
-)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partitions.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partitions.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partitions.sql
deleted file mode 100644
index 7b279af..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/partitions.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE PARTITIONS (
-  PARTITION_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  TID INT NOT NULL,
-  PARTITION_NAME VARCHAR(767) BINARY,
-  PATH VARCHAR(4096),
-  UNIQUE INDEX PARTITIONS_IDX (PARTITION_ID, TID, PARTITION_NAME),
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/stats.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/stats.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/stats.sql
deleted file mode 100644
index bba8ee7..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/stats.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE STATS (
-  TID INT NOT NULL PRIMARY KEY,
-  NUM_ROWS BIGINT,
-  NUM_BYTES BIGINT,
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
-)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/table_properties.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/table_properties.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/table_properties.sql
deleted file mode 100644
index b9a84e0..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/table_properties.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE OPTIONS (
-  TID INT NOT NULL,
-  KEY_ VARCHAR(255) BINARY NOT NULL,
-  VALUE_ VARCHAR(4000) NOT NULL,
-  PRIMARY KEY (TID, KEY_),
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/tables.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/tables.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/tables.sql
deleted file mode 100644
index a31f0e3..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/tables.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-CREATE TABLE TABLES (
-  TID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  DB_ID INT NOT NULL,
-  TABLE_NAME VARCHAR(128) BINARY NOT NULL,
-  TABLE_TYPE VARCHAR(128) NOT NULL,
-  PATH VARCHAR(4096),
-  STORE_TYPE CHAR(16),
-  FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID),
-  INDEX IDX_DB_ID (DB_ID),
-  UNIQUE INDEX IDX_TABLE_ID (DB_ID, TABLE_NAME)
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/tablespaces.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/tablespaces.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/tablespaces.sql
deleted file mode 100644
index ab3edaa..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mariadb/tablespaces.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE TABLESPACES (
-  SPACE_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  SPACE_NAME VARCHAR(128) BINARY NOT NULL UNIQUE,
-  SPACE_HANDLER VARCHAR (1024) DEFAULT 'HDFS',
-  SPACE_URI VARCHAR (4096) NOT NULL,
-  UNIQUE INDEX IDX_NAME (SPACE_NAME)
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/columns.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/columns.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/columns.sql
deleted file mode 100644
index 5b8ed26..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/columns.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-CREATE TABLE COLUMNS (
-  TID INT NOT NULL,
-  COLUMN_NAME VARCHAR(255) BINARY NOT NULL,
-  ORDINAL_POSITION INT NOT NULL,
-  NESTED_FIELD_NUM INT NOT NULL,
-  DATA_TYPE CHAR(16),
-  TYPE_LENGTH INTEGER,
-  PRIMARY KEY (TID, ORDINAL_POSITION),
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/databases.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/databases.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/databases.sql
deleted file mode 100644
index 2f351cf..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/databases.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE DATABASES_ (
-  DB_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  DB_NAME VARCHAR(128) BINARY NOT NULL UNIQUE,
-  SPACE_ID INT NOT NULL,
-  FOREIGN KEY (SPACE_ID) REFERENCES TABLESPACES (SPACE_ID),
-  UNIQUE INDEX IDX_NAME (DB_NAME)
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/indexes.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/indexes.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/indexes.sql
deleted file mode 100644
index f58b17c..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/indexes.sql
+++ /dev/null
@@ -1,16 +0,0 @@
-CREATE TABLE INDEXES (
-  DB_ID INT NOT NULL,
-  TID INT NOT NULL,
-  INDEX_NAME VARCHAR(128) BINARY NOT NULL,
-  COLUMN_NAME VARCHAR(128) BINARY NOT NULL,
-  DATA_TYPE VARCHAR(128) NOT NULL,
-  INDEX_TYPE CHAR(32) NOT NULL,
-  IS_UNIQUE BOOLEAN NOT NULL,
-  IS_CLUSTERED BOOLEAN NOT NULL,
-  IS_ASCENDING BOOLEAN NOT NULL,
-  PRIMARY KEY (DB_ID, INDEX_NAME),
-  FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID) ON DELETE CASCADE,
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE,
-  UNIQUE INDEX IDX_DB_ID_NAME (DB_ID, INDEX_NAME),
-  INDEX IDX_TID_COLUMN_NAME (TID, COLUMN_NAME)
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/mysql.xml
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/mysql.xml b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/mysql.xml
new file mode 100644
index 0000000..34337fb
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/mysql.xml
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<tns:store xmlns:tns="http://tajo.apache.org/catalogstore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
+  <!--
+    Catalog base version history
+    * 4 - 2015-03-27: Partition Schema (TAJO-1284)
+    * 3 - 2015-03-12: Nested Schema (TAJO-1329)
+    * 2 - 2014-06-09: First versioning
+    * 1-  Before 2013-03-20
+  -->
+  <tns:base version="4">
+    <tns:objects>
+      <tns:Object order="0" type="table" name="META">
+        <tns:sql><![CDATA[CREATE TABLE META (VERSION INT NOT NULL)]]></tns:sql>
+      </tns:Object>
+      <tns:Object order="1" type="table" name="TABLESPACES">
+        <tns:sql><![CDATA[
+        CREATE TABLE TABLESPACES (
+          SPACE_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+          SPACE_NAME VARCHAR(128) BINARY NOT NULL UNIQUE,
+          SPACE_HANDLER VARCHAR (1024) DEFAULT 'HDFS',
+          SPACE_URI VARCHAR (4096) BINARY NOT NULL,
+          UNIQUE INDEX IDX_NAME (SPACE_NAME)
+				)]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="2" type="table" name="DATABASES_">
+        <tns:sql><![CDATA[
+        CREATE TABLE DATABASES_ (
+          DB_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+          DB_NAME VARCHAR(128) BINARY NOT NULL UNIQUE,
+          SPACE_ID INT NOT NULL,
+          FOREIGN KEY (SPACE_ID) REFERENCES TABLESPACES (SPACE_ID),
+          UNIQUE INDEX IDX_NAME (DB_NAME)
+				)]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="3" type="table" name="TABLES">
+        <tns:sql><![CDATA[
+        CREATE TABLE TABLES (
+          TID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+          DB_ID INT NOT NULL,
+          TABLE_NAME VARCHAR(128) BINARY NOT NULL,
+          TABLE_TYPE VARCHAR(128) NOT NULL,
+          PATH VARCHAR(4096) BINARY,
+          STORE_TYPE CHAR(16),
+          FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID),
+          INDEX IDX_DB_ID (DB_ID),
+          UNIQUE INDEX IDX_TABLE_ID (DB_ID, TABLE_NAME)
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="4" type="table" name="COLUMNS">
+        <tns:sql><![CDATA[
+        CREATE TABLE COLUMNS (
+          TID INT NOT NULL,
+          COLUMN_NAME VARCHAR(255) BINARY NOT NULL,
+          ORDINAL_POSITION INT NOT NULL,
+          NESTED_FIELD_NUM INT NOT NULL,
+          DATA_TYPE CHAR(16),
+          TYPE_LENGTH INTEGER,
+          PRIMARY KEY (TID, ORDINAL_POSITION),
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="5" type="table" name="OPTIONS">
+        <tns:sql><![CDATA[
+        CREATE TABLE OPTIONS (
+          TID INT NOT NULL,
+          KEY_ VARCHAR(255) BINARY NOT NULL,
+          VALUE_ VARCHAR(4000) NOT NULL,
+          PRIMARY KEY (TID, KEY_),
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+
+      <tns:Object order="6" type="table" name="INDEXES">
+        <tns:sql><![CDATA[
+        CREATE TABLE INDEXES (
+          DB_ID INT NOT NULL,
+          TID INT NOT NULL,
+          INDEX_NAME VARCHAR(128) BINARY NOT NULL,
+          COLUMN_NAME VARCHAR(128) BINARY NOT NULL,
+          DATA_TYPE VARCHAR(128) NOT NULL,
+          INDEX_TYPE CHAR(32) NOT NULL,
+          IS_UNIQUE BOOLEAN NOT NULL,
+          IS_CLUSTERED BOOLEAN NOT NULL,
+          IS_ASCENDING BOOLEAN NOT NULL,
+          PRIMARY KEY (DB_ID, INDEX_NAME),
+          FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID) ON DELETE CASCADE,
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE,
+          UNIQUE INDEX IDX_DB_ID_NAME (DB_ID, INDEX_NAME),
+          INDEX IDX_TID_COLUMN_NAME (TID, COLUMN_NAME)
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="7" type="table" name="STATS">
+        <tns:sql><![CDATA[
+        CREATE TABLE STATS (
+          TID INT NOT NULL PRIMARY KEY,
+          NUM_ROWS BIGINT,
+          NUM_BYTES BIGINT,
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="8" type="table" name="PARTITION_METHODS">
+        <tns:sql><![CDATA[
+        CREATE TABLE PARTITION_METHODS (
+          TID INT NOT NULL PRIMARY KEY,
+          PARTITION_TYPE VARCHAR(10) NOT NULL,
+          EXPRESSION VARCHAR(1024) NOT NULL,
+          EXPRESSION_SCHEMA VARCHAR(1024) NOT NULL,
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="9" type="table" name="PARTITIONS">
+        <tns:sql><![CDATA[
+        CREATE TABLE PARTITIONS (
+          PARTITION_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+          TID INT NOT NULL,
+          PARTITION_NAME VARCHAR(255) BINARY,
+          PATH VARCHAR(4096) BINARY,
+          CONSTRAINT CONST_PARTITION_UNIQUE UNIQUE (PARTITION_NAME),
+          FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+      <tns:Object order="10" type="table" name="PARTITION_KEYS">
+        <tns:sql><![CDATA[
+        CREATE TABLE PARTITION_KEYS (
+          PARTITION_ID INT NOT NULL,
+          COLUMN_NAME VARCHAR(255) BINARY NOT NULL,
+          PARTITION_VALUE VARCHAR(255) BINARY NOT NULL,
+          UNIQUE INDEX PARTITION_KEYS_IDX (PARTITION_ID, COLUMN_NAME, PARTITION_VALUE),
+          FOREIGN KEY (PARTITION_ID) REFERENCES PARTITIONS (PARTITION_ID) ON DELETE CASCADE
+        )]]>
+        </tns:sql>
+      </tns:Object>
+    </tns:objects>
+  </tns:base>
+
+</tns:store>

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partition_keys.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partition_keys.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partition_keys.sql
deleted file mode 100644
index 6f2f238..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partition_keys.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE PARTITION_KEYS (
-  PARTITION_ID INT NOT NULL,
-  COLUMN_NAME VARCHAR(255) BINARY NOT NULL,
-  PARTITION_VALUE VARCHAR(255) NOT NULL,
-  UNIQUE INDEX PARTITION_KEYS_IDX (PARTITION_ID, COLUMN_NAME, PARTITION_VALUE),
-  FOREIGN KEY (PARTITION_ID) REFERENCES PARTITIONS (PARTITION_ID) ON DELETE CASCADE)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partition_methods.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partition_methods.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partition_methods.sql
deleted file mode 100644
index 060c4c8..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partition_methods.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE PARTITION_METHODS (
-  TID INT NOT NULL PRIMARY KEY,
-  PARTITION_TYPE VARCHAR(10) NOT NULL,
-  EXPRESSION VARCHAR(1024) NOT NULL,
-  EXPRESSION_SCHEMA VARCHAR(1024) NOT NULL,
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
-)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partitions.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partitions.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partitions.sql
deleted file mode 100644
index 7b279af..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/partitions.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE PARTITIONS (
-  PARTITION_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  TID INT NOT NULL,
-  PARTITION_NAME VARCHAR(767) BINARY,
-  PATH VARCHAR(4096),
-  UNIQUE INDEX PARTITIONS_IDX (PARTITION_ID, TID, PARTITION_NAME),
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/stats.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/stats.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/stats.sql
deleted file mode 100644
index bba8ee7..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/stats.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE STATS (
-  TID INT NOT NULL PRIMARY KEY,
-  NUM_ROWS BIGINT,
-  NUM_BYTES BIGINT,
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
-)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/table_properties.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/table_properties.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/table_properties.sql
deleted file mode 100644
index b9a84e0..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/table_properties.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE OPTIONS (
-  TID INT NOT NULL,
-  KEY_ VARCHAR(255) BINARY NOT NULL,
-  VALUE_ VARCHAR(4000) NOT NULL,
-  PRIMARY KEY (TID, KEY_),
-  FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/tables.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/tables.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/tables.sql
deleted file mode 100644
index 0fe8bf2..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/tables.sql
+++ /dev/null
@@ -1,11 +0,0 @@
-CREATE TABLE TABLES (
-  TID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  DB_ID INT NOT NULL,
-  TABLE_NAME VARCHAR(128) BINARY NOT NULL,
-  TABLE_TYPE VARCHAR(128) NOT NULL,
-  PATH VARCHAR(4096) BINARY,
-  STORE_TYPE CHAR(16),
-  FOREIGN KEY (DB_ID) REFERENCES DATABASES_ (DB_ID),
-  INDEX IDX_DB_ID (DB_ID),
-  UNIQUE INDEX IDX_TABLE_ID (DB_ID, TABLE_NAME)
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/tablespaces.sql
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/tablespaces.sql b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/tablespaces.sql
deleted file mode 100644
index 3cfbb40..0000000
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/mysql/tablespaces.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE TABLESPACES (
-  SPACE_ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  SPACE_NAME VARCHAR(128) BINARY NOT NULL UNIQUE,
-  SPACE_HANDLER VARCHAR (1024) DEFAULT 'HDFS',
-  SPACE_URI VARCHAR (4096) BINARY NOT NULL,
-  UNIQUE INDEX IDX_NAME (SPACE_NAME)
-)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/oracle.xml
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/oracle.xml b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/oracle.xml
index 8c28b97..323e22c 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/oracle.xml
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/oracle/oracle.xml
@@ -17,12 +17,14 @@
   limitations under the License.
   -->
 <tns:store xmlns:tns="http://tajo.apache.org/catalogstore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
-
-  <!-- Version History -->
-  <!-- 3 - 2015-03-12: Nested Schema (TAJO-1329) -->
-  <!-- 2 - First versioning -->
-
-  <tns:base version="3">
+  <!--
+      Catalog base version history
+      * 4 - 2015-03-27: Partition Schema (TAJO-1284)
+      * 3 - 2015-03-12: Nested Schema (TAJO-1329)
+      * 2 - 2014-06-09: First versioning
+      * 1-  Before 2013-03-20
+    -->
+  <tns:base version="4">
     <tns:objects>
   		<tns:Object order="0" type="table" name="meta">
   			<tns:sql><![CDATA[
@@ -211,10 +213,7 @@
 				END;]]>
         </tns:sql>
       </tns:Object>
-  		<tns:Object order="21" type="index" name="PARTITIONS_IDX" dependsOn="PARTITIONS">
-  			<tns:sql><![CDATA[CREATE INDEX PARTITIONS_IDX on PARTITIONS (PARTITION_ID, TID, PARTITION_NAME)]]></tns:sql>
-  		</tns:Object>
-      <tns:Object order="22" type="table" name="PARTITION_KEYS">
+      <tns:Object order="21" type="table" name="PARTITION_KEYS">
         <tns:sql><![CDATA[
           CREATE TABLE PARTITION_KEYS (
             PARTITION_ID INT NOT NULL,

http://git-wip-us.apache.org/repos/asf/tajo/blob/bda2d623/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/postgresql/postgresql.xml
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/postgresql/postgresql.xml b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/postgresql/postgresql.xml
index 56bc3a3..554acd5 100644
--- a/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/postgresql/postgresql.xml
+++ b/tajo-catalog/tajo-catalog-server/src/main/resources/schemas/postgresql/postgresql.xml
@@ -19,12 +19,14 @@
 <tns:store xmlns:tns="http://tajo.apache.org/catalogstore" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.xsd ">
-
-  <!-- Version History -->
-  <!-- 3 - 2015-03-12: Nested Schema (TAJO-1329) -->
-  <!-- 2 - First versioning -->
-
-	<tns:base version="3">
+  <!--
+      Catalog base version history
+      * 4 - 2015-03-27: Partition Schema (TAJO-1284)
+      * 3 - 2015-03-12: Nested Schema (TAJO-1329)
+      * 2 - 2014-06-09: First versioning
+      * 1-  Before 2013-03-20
+    -->
+	<tns:base version="4">
 		<tns:objects>
 			<tns:Object name="META" type="table" order="0">
 				<tns:sql><![CDATA[CREATE TABLE META (VERSION INT NOT NULL)]]></tns:sql>
@@ -154,17 +156,11 @@ xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.
   				PARTITION_VALUE VARCHAR(1024),
   				PATH VARCHAR(4096),
   				FOREIGN KEY (TID) REFERENCES TABLES (TID) ON DELETE CASCADE,
-  				CONSTRAINT C_PARTITION_UNIQUE UNIQUE (TID, PARTITION_NAME)
+  				CONSTRAINT C_PARTITION_UNIQUE UNIQUE (PARTITION_NAME)
 				)]]>
 				</tns:sql>
 			</tns:Object>
-			<tns:Object name="PARTITIONS_IDX_TID" type="index" order="16" dependsOn="PARTITIONS">
-				<tns:sql><![CDATA[CREATE INDEX PARTITIONS_IDX_TID on PARTITIONS (TID)]]></tns:sql>
-			</tns:Object>
-			<tns:Object name="IDX_TID_NAME" type="index" order="17" dependsOn="PARTITIONS">
-				<tns:sql><![CDATA[CREATE UNIQUE INDEX IDX_TID_NAME on PARTITIONS (TID, PARTITION_NAME)]]></tns:sql>
-			</tns:Object>
-      <tns:Object name="PARTITION_KEYS" type="table" order="18">
+      <tns:Object name="PARTITION_KEYS" type="table" order="16">
         <tns:sql><![CDATA[
           CREATE TABLE PARTITION_KEYS (
             PARTITION_ID INT NOT NULL,
@@ -174,7 +170,7 @@ xsi:schemaLocation="http://tajo.apache.org/catalogstore ../DBMSSchemaDefinition.
 				)]]>
         </tns:sql>
       </tns:Object>
-      <tns:Object name="PARTITION_KEYS_IDX" type="index" order="19" dependsOn="PARTITION_KEYS">
+      <tns:Object name="PARTITION_KEYS_IDX" type="index" order="17" dependsOn="PARTITION_KEYS">
         <tns:sql><![CDATA[CREATE INDEX PARTITION_KEYS_IDX on PARTITION_KEYS (PARTITION_ID, COLUMN_NAME, PARTITION_VALUE)]]></tns:sql>
       </tns:Object>
 		</tns:objects>


Mime
View raw message