tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [1/2] tajo git commit: TAJO-1813: Allow external catalog store for unit testing.
Date Wed, 16 Sep 2015 03:33:28 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 59fe67841 -> 7d97284a9


http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogAgainstCaseSensitivity.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogAgainstCaseSensitivity.java b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogAgainstCaseSensitivity.java
new file mode 100644
index 0000000..bfff6b4
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogAgainstCaseSensitivity.java
@@ -0,0 +1,492 @@
+/**
+ * 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;
+
+import org.apache.tajo.catalog.partition.PartitionDesc;
+import org.apache.tajo.catalog.proto.CatalogProtos.*;
+import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.AlterTablespaceCommand;
+import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.AlterTablespaceType;
+import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.SetLocation;
+import org.apache.tajo.catalog.statistics.TableStats;
+import org.apache.tajo.common.TajoDataTypes.Type;
+import org.apache.tajo.exception.UndefinedPartitionException;
+import org.apache.tajo.exception.UndefinedTableException;
+import org.apache.tajo.util.CommonTestingUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.net.URI;
+import java.util.*;
+
+import static org.junit.Assert.*;
+
+public class TestCatalogAgainstCaseSensitivity {
+  static CatalogServer server;
+  static CatalogService catalog;
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    server = new MiniCatalogServer();
+    catalog = new LocalCatalogWrapper(server);
+    CatalogTestingUtil.prepareBaseData(catalog, ((MiniCatalogServer) server).getTestDir());
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    CatalogTestingUtil.cleanupBaseData(catalog);
+    server.stop();
+  }
+
+  @Test
+  public void testTablespace() throws Exception {
+    assertTrue(catalog.existTablespace("space1"));
+    assertTrue(catalog.existTablespace("SpAcE1"));
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test alter tablespace
+    //////////////////////////////////////////////////////////////////////////////
+
+    catalog.alterTablespace(AlterTablespaceProto.newBuilder().
+        setSpaceName("space1").
+        addCommand(
+            AlterTablespaceCommand.newBuilder().
+                setType(AlterTablespaceType.LOCATION).
+                setLocation(SetLocation.newBuilder()
+                    .setUri("hdfs://zzz.com/warehouse"))).build());
+
+    catalog.alterTablespace(AlterTablespaceProto.newBuilder().
+        setSpaceName("SpAcE1").
+        addCommand(
+            AlterTablespaceCommand.newBuilder().
+                setType(AlterTablespaceType.LOCATION).
+                setLocation(SetLocation.newBuilder()
+                    .setUri("hdfs://zzz.com/warehouse"))).build());
+
+    Set<TablespaceProto> tablespaceProtos = new HashSet<>();
+    for (String tablespaceName : catalog.getAllTablespaceNames()) {
+      assertTrue(tablespaceName + " does not exist.", catalog.existTablespace(tablespaceName));
+      tablespaceProtos.add(catalog.getTablespace(tablespaceName));
+    }
+    assertEquals(tablespaceProtos, new HashSet<>(catalog.getAllTablespaces()));
+  }
+
+  @Test
+  public void testDatabase() throws Exception {
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get all databases
+    //////////////////////////////////////////////////////////////////////////////
+
+    assertTrue(catalog.existDatabase("TestDatabase1"));
+    assertTrue(catalog.existDatabase("testDatabase1"));
+    assertTrue(catalog.getAllDatabaseNames().contains("TestDatabase1"));
+    assertTrue(catalog.getAllDatabaseNames().contains("testDatabase1"));
+  }
+
+  @Test
+  public void testTable() throws Exception {
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get all tables
+    //////////////////////////////////////////////////////////////////////////////
+
+    assertTrue(catalog.existsTable("TestDatabase1", "TestTable1"));
+    assertTrue(catalog.existsTable("TestDatabase1", "testTable1"));
+
+    Map<String, TableDesc> tableDescs = new HashMap<>();
+    for (String eachTableName : catalog.getAllTableNames("TestDatabase1")) {
+      TableDesc desc = catalog.getTableDesc("TestDatabase1", eachTableName);
+      tableDescs.put(desc.getName(), desc);
+    }
+    for (TableDescriptorProto eachTableDescriptor : catalog.getAllTables()) {
+      String qualifiedTableName = CatalogUtil.buildFQName("TestDatabase1", eachTableDescriptor.getName());
+      assertTrue(tableDescs.containsKey(qualifiedTableName));
+      TableDesc desc = tableDescs.get(qualifiedTableName);
+      assertEquals(desc.getUri().toString(), eachTableDescriptor.getPath());
+      assertEquals(desc.getMeta().getStoreType(), eachTableDescriptor.getStoreType());
+    }
+
+    //////////////////////////////////////////////////////////////////////////////
+    // rename table
+    //////////////////////////////////////////////////////////////////////////////
+
+    TableDesc desc = CatalogTestingUtil.buildTableDesc("TestDatabase1", "newTable",
+        CommonTestingUtil.getTestDir().toString());
+    catalog.createTable(desc);
+
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setAlterTableType(AlterTableType.RENAME_TABLE);
+    alterTableDesc.setNewTableName(CatalogUtil.buildFQName("TestDatabase1", "renamed_table"));
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "newTable"));
+    catalog.alterTable(alterTableDesc);
+
+    assertFalse(catalog.existsTable("TestDatabase1", "newTable"));
+    assertTrue(catalog.existsTable("TestDatabase1", "renamed_table"));
+    catalog.dropTable(CatalogUtil.buildFQName("TestDatabase1", "renamed_table"));
+
+    //////////////////////////////////////////////////////////////////////////////
+    // table stats
+    //////////////////////////////////////////////////////////////////////////////
+
+    TableStats stats = catalog.getTableDesc("TestDatabase1", "TestTable1").getStats();
+    assertEquals(10000, stats.getNumBytes().longValue());
+    assertEquals(5000, stats.getNumRows().longValue());
+  }
+
+  @Test
+  public void testTablePartition() throws Exception {
+    //////////////////////////////////////////////////////////////////////////////
+    // Test add partition
+    //////////////////////////////////////////////////////////////////////////////
+
+    assertTrue(catalog.existsTable("TestDatabase1", "TestPartition1"));
+    assertTrue(catalog.existsTable("TestDatabase1", "testPartition1"));
+
+    String partitionName = "DaTe=bBb/dAtE=AaA";
+    PartitionDesc partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestPartition1"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.ADD_PARTITION);
+
+    catalog.alterTable(alterTableDesc);
+
+    PartitionDescProto resultDesc = catalog.getPartition("TestDatabase1", "TestPartition1",
+        partitionName);
+
+    assertNotNull(resultDesc);
+    assertEquals(resultDesc.getPartitionName(), partitionName);
+    assertEquals(resultDesc.getPath(), "hdfs://xxx.com/warehouse/" + partitionName);
+    assertEquals(resultDesc.getPartitionKeysCount(), 2);
+
+    partitionName = "DaTe=BbB/dAtE=aAa";
+    partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestPartition1"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.ADD_PARTITION);
+
+    catalog.alterTable(alterTableDesc);
+
+    resultDesc = catalog.getPartition("TestDatabase1", "TestPartition1",
+        partitionName);
+
+    assertNotNull(resultDesc);
+    assertEquals(resultDesc.getPartitionName(), partitionName);
+    assertEquals(resultDesc.getPath(), "hdfs://xxx.com/warehouse/" + partitionName);
+    assertEquals(resultDesc.getPartitionKeysCount(), 2);
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get partitions of a table
+    //////////////////////////////////////////////////////////////////////////////
+
+    List<PartitionDescProto> partitionDescs = catalog.getPartitions("TestDatabase1", "TestPartition1");
+    assertEquals(2, partitionDescs.size());
+    Map<String, PartitionDescProto> tablePartitionMap = new HashMap<>();
+    for (PartitionDescProto eachPartition : partitionDescs) {
+      tablePartitionMap.put(eachPartition.getPartitionName(), eachPartition);
+    }
+    assertTrue(tablePartitionMap.containsKey("DaTe=bBb/dAtE=AaA"));
+    assertTrue(tablePartitionMap.containsKey("DaTe=BbB/dAtE=aAa"));
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get all partitions
+    //////////////////////////////////////////////////////////////////////////////
+
+    List<TablePartitionProto> partitions = catalog.getAllPartitions();
+    assertEquals(2, partitions.size());
+    Map<String, TablePartitionProto> partitionMap = new HashMap<>();
+    for (TablePartitionProto eachPartition : partitions) {
+      partitionMap.put(eachPartition.getPartitionName(), eachPartition);
+    }
+    assertTrue(partitionMap.containsKey("DaTe=bBb/dAtE=AaA"));
+    assertTrue(partitionMap.containsKey("DaTe=BbB/dAtE=aAa"));
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test drop partition
+    //////////////////////////////////////////////////////////////////////////////
+
+    partitionName = "DaTe=BbB/dAtE=aAa";
+    partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestPartition1"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.DROP_PARTITION);
+    catalog.alterTable(alterTableDesc);
+
+    try {
+      resultDesc = null;
+      resultDesc = catalog.getPartition("TestDatabase1", "TestPartition1", partitionName);
+    } catch (UndefinedPartitionException e) {
+    }
+    assertNull(resultDesc);
+
+    partitionName = "DaTe=bBb/dAtE=AaA";
+    partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestPartition1"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.DROP_PARTITION);
+    catalog.alterTable(alterTableDesc);
+
+    try {
+      resultDesc = null;
+      resultDesc = catalog.getPartition("TestDatabase1", "TestPartition1", partitionName);
+    } catch (UndefinedPartitionException e) {
+    }
+    assertNull(resultDesc);
+  }
+
+  @Test
+  public void testTableColumn() throws Exception {
+    String databaseName = "TestDatabase1";
+    String tableName = "testTable1";
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test add column
+    //////////////////////////////////////////////////////////////////////////////
+
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setAddColumn(new Column(CatalogUtil.buildFQName(databaseName, tableName, "AddedCol1"),
+        CatalogUtil.newSimpleDataType(Type.BLOB)));
+    alterTableDesc.setTableName(CatalogUtil.buildFQName(databaseName, tableName));
+    alterTableDesc.setAlterTableType(AlterTableType.ADD_COLUMN);
+    catalog.alterTable(alterTableDesc);
+
+    TableDesc tableDesc = catalog.getTableDesc(databaseName, tableName);
+    assertTrue(
+        tableDesc.getSchema().containsByQualifiedName(CatalogUtil.buildFQName(databaseName, tableName, "AddedCol1")));
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test rename column
+    //////////////////////////////////////////////////////////////////////////////
+
+    alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setColumnName(CatalogUtil.buildFQName(databaseName, tableName, "AddedCol1"));
+    alterTableDesc.setNewColumnName(CatalogUtil.buildFQName(databaseName, tableName, "addedcol1"));
+    alterTableDesc.setTableName(CatalogUtil.buildFQName(databaseName, tableName));
+    alterTableDesc.setAlterTableType(AlterTableType.RENAME_COLUMN);
+    catalog.alterTable(alterTableDesc);
+
+    tableDesc = catalog.getTableDesc(databaseName, tableName);
+    assertFalse(
+        tableDesc.getSchema().containsByQualifiedName(CatalogUtil.buildFQName(databaseName, tableName, "AddedCol1")));
+    assertTrue(
+        tableDesc.getSchema().containsByQualifiedName(CatalogUtil.buildFQName(databaseName, tableName, "addedcol1")));
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get all columns
+    //////////////////////////////////////////////////////////////////////////////
+
+    int columnCount = 0;
+    for (ColumnProto eachColumnProto : catalog.getAllColumns()) {
+      Column column = new Column(eachColumnProto);
+      tableDesc = catalog.getTableDesc(column.getQualifier());
+      assertTrue(tableDesc.getLogicalSchema().contains(column));
+      columnCount++;
+    }
+
+    // TODO: Since the logical schema includes partition column keys, it should be compared in the below.
+    // However, comparing logical schema causes test failure due to the bug of AbstractDBStore.
+    int expected = 0;
+    for (String eachTableName : catalog.getAllTableNames(databaseName)) {
+      expected += catalog.getTableDesc(databaseName, eachTableName).getSchema().size();
+    }
+    assertEquals(expected, columnCount);
+  }
+
+  @Test
+  public void testTableColumnWithNestedField() throws Exception {
+    String databaseName = "TestDatabase1";
+    String tableName = "nested_Table";
+
+    Schema schema = new Schema(
+        new Column[]{
+            new Column("CoL1", CatalogUtil.newSimpleDataType(Type.INT4)),
+            new Column("CoL2", CatalogUtil.newSimpleDataType(Type.FLOAT4)),
+            new Column("CoL3", CatalogUtil.newSimpleDataType(Type.TEXT)),
+    });
+
+    Schema tableSchema = new Schema();
+    tableSchema.addColumn("RecoRd1", new TypeDesc(schema));
+    tableSchema.addColumn("CoL1", CatalogUtil.newSimpleDataType(Type.INT4));
+    tableSchema.addColumn("CoL3", CatalogUtil.newSimpleDataType(Type.TEXT));
+    tableSchema.addColumn("RecoRd2", new TypeDesc(schema));
+    tableSchema.addColumn("RecoRd3", new TypeDesc(
+        new Schema(new Column[]{
+            new Column("CoL1", CatalogUtil.newSimpleDataType(Type.INT4)),
+            new Column("RecoRd1", new TypeDesc(schema)),
+        })
+    ));
+
+    TableDesc tableDesc = new TableDesc(
+        CatalogUtil.buildFQName(databaseName, tableName),
+        tableSchema,
+        CatalogUtil.newTableMeta("JSON"),
+        URI.create("hdfs://xxx.com/json_Table")
+    );
+
+    catalog.createTable(tableDesc);
+    assertTrue(catalog.existsTable(databaseName, tableName));
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get table desc
+    //////////////////////////////////////////////////////////////////////////////
+
+    tableSchema = catalog.getTableDesc(databaseName, tableName).getSchema();
+    assertTrue(tableSchema.contains("RecoRd1"));
+    assertTrue(tableSchema.contains(new Column("CoL1", CatalogUtil.newSimpleDataType(Type.INT4))));
+    assertTrue(tableSchema.contains(new Column("CoL3", CatalogUtil.newSimpleDataType(Type.TEXT))));
+    assertTrue(tableSchema.contains("RecoRd2"));
+    assertTrue(tableSchema.contains("RecoRd3"));
+
+    schema = tableSchema.getColumn("RecoRd1").getTypeDesc().nestedRecordSchema;
+    assertTrue(schema.contains(new Column("CoL1", CatalogUtil.newSimpleDataType(Type.INT4))));
+    assertTrue(schema.contains(new Column("CoL2", CatalogUtil.newSimpleDataType(Type.FLOAT4))));
+    assertTrue(schema.contains(new Column("CoL3", CatalogUtil.newSimpleDataType(Type.TEXT))));
+
+    schema = tableSchema.getColumn("RecoRd2").getTypeDesc().nestedRecordSchema;
+    assertTrue(schema.contains(new Column("CoL1", CatalogUtil.newSimpleDataType(Type.INT4))));
+    assertTrue(schema.contains(new Column("CoL2", CatalogUtil.newSimpleDataType(Type.FLOAT4))));
+    assertTrue(schema.contains(new Column("CoL3", CatalogUtil.newSimpleDataType(Type.TEXT))));
+
+    schema = tableSchema.getColumn("RecoRd3").getTypeDesc().nestedRecordSchema;
+    assertTrue(schema.contains(new Column("CoL1", CatalogUtil.newSimpleDataType(Type.INT4))));
+    assertTrue(tableSchema.contains("RecoRd1"));
+
+    schema = schema.getColumn("RecoRd1").getTypeDesc().nestedRecordSchema;
+    assertTrue(schema.contains(new Column("CoL1", CatalogUtil.newSimpleDataType(Type.INT4))));
+    assertTrue(schema.contains(new Column("CoL2", CatalogUtil.newSimpleDataType(Type.FLOAT4))));
+    assertTrue(schema.contains(new Column("CoL3", CatalogUtil.newSimpleDataType(Type.TEXT))));
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get all columns
+    //////////////////////////////////////////////////////////////////////////////
+
+    int columnCount = 0;
+    for (ColumnProto eachColumnProto : catalog.getAllColumns()) {
+      // TODO: nested columns must have their name properly.
+      // TODO: For example, the 'RecoRd1.CoL1' column of the above test table
+      // TODO: has name of 'TestDatabase1.nested_Table.RecoRd1.CoL1'.
+
+//      Column column = new Column(eachColumnProto);
+//      tableDesc = catalog.getTableDesc(column.getQualifier());
+//      assertTrue(column.getQualifiedName() + " must be contained in " + tableDesc.getName(),
+//          tableDesc.getLogicalSchema().contains(column));
+      columnCount++;
+    }
+    
+    int expected = 0;
+    for (String eachTableName : catalog.getAllTableNames(databaseName)) {
+      expected += catalog.getTableDesc(databaseName, eachTableName).getSchema().getAllColumns().size();
+    }
+    assertEquals(expected, columnCount);
+  }
+
+  @Test
+  public void testTableProperty() throws UndefinedTableException {
+    String databaseName = "TestDatabase1";
+    String tableName = "testTable1";
+
+    TableDesc tableDesc = catalog.getTableDesc(databaseName, tableName);
+    assertEquals("ThisIsTest", tableDesc.getMeta().getOption("testString"));
+    assertEquals("true", tableDesc.getMeta().getOption("testBool"));
+    assertEquals("0.2", tableDesc.getMeta().getOption("testFloat"));
+    assertEquals("60", tableDesc.getMeta().getOption("testInt"));
+    assertEquals("800", tableDesc.getMeta().getOption("testLong"));
+  }
+
+  @Test
+  public void testIndex() throws Exception {
+    String databaseName = "TestDatabase1";
+    String tableName = "testTable1";
+    String indexName = "thisIs_newIndex";
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test create index
+    //////////////////////////////////////////////////////////////////////////////
+
+    Set<IndexDesc> originalIndexes = new HashSet<>();
+    TableDesc tableDesc = catalog.getTableDesc(databaseName, tableName);
+    IndexDesc originalIndexDesc = CatalogTestingUtil.buildIndexDescs(databaseName, "newIndex2", tableDesc,
+        tableDesc.getSchema().getColumn(0), tableDesc.getSchema().getColumn(1), tableDesc.getSchema().getColumn(2));
+    originalIndexes.add(originalIndexDesc);
+    catalog.createIndex(originalIndexDesc);
+
+    originalIndexDesc = CatalogTestingUtil.buildIndexDescs(databaseName, indexName, tableDesc,
+        tableDesc.getSchema().getColumn(0), tableDesc.getSchema().getColumn(2));
+    originalIndexes.add(originalIndexDesc);
+    catalog.createIndex(originalIndexDesc);
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get index with index name
+    //////////////////////////////////////////////////////////////////////////////
+
+    assertTrue(catalog.existIndexByName(databaseName, indexName));
+    IndexDesc indexDesc = catalog.getIndexByName(databaseName, indexName);
+    assertEquals(originalIndexDesc, indexDesc);
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get index with columns
+    //////////////////////////////////////////////////////////////////////////////
+
+    String[] indexKeyNames = new String[2];
+    indexKeyNames[0] = tableDesc.getSchema().getColumn(0).getQualifiedName();
+    indexKeyNames[1] = tableDesc.getSchema().getColumn(2).getQualifiedName();
+    assertTrue(catalog.existIndexByColumnNames(databaseName, tableName, indexKeyNames));
+    indexDesc = catalog.getIndexByColumnNames(databaseName, tableName, indexKeyNames);
+    assertEquals(originalIndexDesc, indexDesc);
+
+    Column[] indexKeys = new Column[2];
+    indexKeys[0] = tableDesc.getSchema().getColumn(0);
+    indexKeys[1] = tableDesc.getSchema().getColumn(2);
+    assertTrue(catalog.existIndexByColumns(databaseName, tableName, indexKeys));
+    indexDesc = catalog.getIndexByColumns(databaseName, tableName, indexKeys);
+    assertEquals(originalIndexDesc, indexDesc);
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get all indexes with table name
+    //////////////////////////////////////////////////////////////////////////////
+
+    Set<IndexDesc> indexDescs = new HashSet<>(catalog.getAllIndexesByTable(databaseName, tableName));
+    assertEquals(originalIndexes, indexDescs);
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test get all indexes
+    //////////////////////////////////////////////////////////////////////////////
+
+    List<IndexDescProto> indexDescProtos = catalog.getAllIndexes();
+    indexDescs = new HashSet<>();
+    for (IndexDescProto indexDescProto : indexDescProtos) {
+      indexDescs.add(new IndexDesc(indexDescProto));
+    }
+    assertEquals(originalIndexes, indexDescs);
+
+    //////////////////////////////////////////////////////////////////////////////
+    // Test drop index
+    //////////////////////////////////////////////////////////////////////////////
+    catalog.dropIndex(databaseName, indexName);
+    assertFalse(catalog.existIndexByName(databaseName, indexName));
+    catalog.dropIndex(databaseName, "newIndex2");
+    assertFalse(catalog.existIndexByName(databaseName, "newIndex2"));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogExceptions.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogExceptions.java b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogExceptions.java
new file mode 100644
index 0000000..7be34d8
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalogExceptions.java
@@ -0,0 +1,293 @@
+/**
+ * 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;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.tajo.TajoConstants;
+import org.apache.tajo.catalog.partition.PartitionDesc;
+import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto;
+import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.AlterTablespaceCommand;
+import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.AlterTablespaceType;
+import org.apache.tajo.catalog.proto.CatalogProtos.AlterTablespaceProto.SetLocation;
+import org.apache.tajo.catalog.proto.CatalogProtos.IndexMethod;
+import org.apache.tajo.catalog.proto.CatalogProtos.TableStatsProto;
+import org.apache.tajo.catalog.proto.CatalogProtos.UpdateTableStatsProto;
+import org.apache.tajo.common.TajoDataTypes.Type;
+import org.apache.tajo.exception.*;
+import org.apache.tajo.util.CommonTestingUtil;
+import org.apache.tajo.util.KeyValueSet;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.net.URI;
+import java.util.UUID;
+
+public class TestCatalogExceptions {
+
+  static CatalogServer server;
+  static CatalogService catalog;
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    server = new MiniCatalogServer();
+    catalog = new LocalCatalogWrapper(server);
+    CatalogTestingUtil.prepareBaseData(catalog, ((MiniCatalogServer) server).getTestDir());
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    CatalogTestingUtil.cleanupBaseData(catalog);
+    server.stop();
+  }
+
+  @Test
+  public void testCreateTablespaceWithWrongUri() throws Exception {
+    // TODO: currently, wrong uri does not occur any exception.
+    catalog.createTablespace("wrong", "hdfs:");
+  }
+
+  @Test(expected = DuplicateTablespaceException.class)
+  public void testCreateDuplicateTablespace() throws Exception {
+    catalog.createTablespace("space1", "hdfs://xxx.com/warehouse");
+  }
+
+  @Test(expected = UndefinedTablespaceException.class)
+  public void testDropUndefinedTablespace() throws Exception {
+    catalog.dropTablespace("undefined");
+  }
+
+  @Test(expected = InsufficientPrivilegeException.class)
+  public void testDropDefaultTablespace() throws Exception {
+    catalog.dropTablespace(TajoConstants.DEFAULT_TABLESPACE_NAME);
+  }
+
+  @Test(expected = TajoInternalError.class)
+  public void testAlterTablespaceWithWrongUri() throws Exception {
+    catalog.alterTablespace(AlterTablespaceProto.newBuilder().
+        setSpaceName("space1").
+        addCommand(
+            AlterTablespaceCommand.newBuilder().
+                setType(AlterTablespaceType.LOCATION).
+                setLocation(SetLocation.newBuilder()
+                    .setUri("hdfs:"))).build());
+  }
+
+  @Test(expected = UndefinedTablespaceException.class)
+  public void testAlterUndefinedTablespace() throws Exception {
+    catalog.alterTablespace(AlterTablespaceProto.newBuilder().
+        setSpaceName("undefined").
+        addCommand(
+            AlterTablespaceCommand.newBuilder().
+                setType(AlterTablespaceType.LOCATION).
+                setLocation(SetLocation.newBuilder()
+                    .setUri("hdfs://zzz.com/warehouse"))).build());
+  }
+
+  @Test(expected = DuplicateDatabaseException.class)
+  public void testCreateDuplicateDatabase() throws Exception {
+    catalog.createDatabase("TestDatabase1", "space1");
+  }
+
+  @Test(expected = UndefinedDatabaseException.class)
+  public void testDropUndefinedDatabase() throws Exception {
+    catalog.dropDatabase("undefined");
+  }
+
+  @Test(expected = InsufficientPrivilegeException.class)
+  public void testDropDefaultDatabase() throws Exception {
+    catalog.dropDatabase(TajoConstants.DEFAULT_DATABASE_NAME);
+  }
+
+  @Test()
+  public void testCreateTableWithWrongUri() throws Exception {
+    // TODO: currently, wrong uri does not occur any exception.
+    String tableName = "wrongUri";
+    Schema schema = new Schema();
+    schema.addColumn(CatalogUtil.buildFQName(tableName, "Column"), Type.BLOB);
+    schema.addColumn(CatalogUtil.buildFQName(tableName, "column"), Type.INT4);
+    schema.addColumn(CatalogUtil.buildFQName(tableName, "cOlumn"), Type.INT8);
+    Path path = new Path(CommonTestingUtil.getTestDir(), tableName);
+    catalog.createTable(
+        new TableDesc(
+            CatalogUtil.buildFQName("TestDatabase1", tableName),
+            schema,
+            new TableMeta("TEXT", new KeyValueSet()),
+            path.toUri(), true));
+  }
+
+  @Test(expected = DuplicateTableException.class)
+  public void testCreateDuplicateTable() throws Exception {
+    catalog.createTable(CatalogTestingUtil.buildTableDesc("TestDatabase1", "TestTable1",
+        CommonTestingUtil.getTestDir().toString()));
+  }
+
+  @Test(expected = UndefinedDatabaseException.class)
+  public void dropTableOfUndefinedDatabase() throws Exception {
+    catalog.dropTable(CatalogUtil.buildFQName("undefined", "testPartition1"));
+  }
+
+  @Test(expected = UndefinedTableException.class)
+  public void dropUndefinedTable() throws Exception {
+    catalog.dropTable(CatalogUtil.buildFQName("TestDatabase1", "undefined"));
+  }
+
+  @Test(expected = UndefinedTableException.class)
+  public void testUpdateTableStatsOfUndefinedTable() throws Exception {
+    catalog.updateTableStats(
+        UpdateTableStatsProto.newBuilder().
+            setTableName(CatalogUtil.buildFQName("TestDatabase1", "undefined")).
+            setStats(
+                TableStatsProto.newBuilder().
+                    setNumRows(0).
+                    setNumBytes(0).
+                    build()).
+            build());
+  }
+
+  @Test
+  public void testAddPartitionWithWrongUri() throws Exception {
+    // TODO: currently, wrong uri does not occur any exception.
+    String partitionName = "DaTe=/=AaA";
+    PartitionDesc partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestPartition1"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.ADD_PARTITION);
+
+    catalog.alterTable(alterTableDesc);
+  }
+
+  @Test(expected = DuplicatePartitionException.class)
+  public void testAddDuplicatePartition() throws Exception {
+    String partitionName = "DaTe=bBb/dAtE=AaA";
+    PartitionDesc partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestPartition1"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.ADD_PARTITION);
+
+    catalog.alterTable(alterTableDesc);
+
+    partitionName = "DaTe=bBb/dAtE=AaA";
+    partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestPartition1"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.ADD_PARTITION);
+
+    catalog.alterTable(alterTableDesc);
+  }
+
+  @Test(expected = UndefinedTableException.class)
+  public void testAddPartitionToUndefinedTable() throws Exception {
+    String partitionName = "DaTe=bBb/dAtE=AaA";
+    PartitionDesc partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "undefined"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.ADD_PARTITION);
+
+    catalog.alterTable(alterTableDesc);
+  }
+
+  @Test(expected = UndefinedPartitionException.class)
+  public void testDropUndefinedPartition() throws Exception {
+    String partitionName = "DaTe=undefined/dAtE=undefined";
+    PartitionDesc partitionDesc = CatalogTestingUtil.buildPartitionDesc(partitionName);
+
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestPartition1"));
+    alterTableDesc.setPartitionDesc(partitionDesc);
+    alterTableDesc.setAlterTableType(AlterTableType.DROP_PARTITION);
+    catalog.alterTable(alterTableDesc);
+  }
+
+  @Test(expected = UndefinedTableException.class)
+  public void testRenameUndefinedTable() throws Exception {
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setAlterTableType(AlterTableType.RENAME_TABLE);
+    alterTableDesc.setNewTableName(CatalogUtil.buildFQName("TestDatabase1", "renamed_table"));
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "undefined"));
+    catalog.alterTable(alterTableDesc);
+  }
+
+  @Test(expected = UndefinedTableException.class)
+  public void testRenameColumnOfUndefinedTable() throws Exception {
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setColumnName(CatalogUtil.buildFQName("TestDatabase1", "undefined", "AddedCol1"));
+    alterTableDesc.setNewColumnName(CatalogUtil.buildFQName("TestDatabase1", "undefined", "addedcol1"));
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "undefined"));
+    alterTableDesc.setAlterTableType(AlterTableType.RENAME_COLUMN);
+    catalog.alterTable(alterTableDesc);
+  }
+
+  @Test(expected = UndefinedColumnException.class)
+  public void testRenameUndefinedColumn() throws Exception {
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setColumnName(CatalogUtil.buildFQName("TestDatabase1", "TestTable1", "undefined"));
+    alterTableDesc.setNewColumnName(CatalogUtil.buildFQName("TestDatabase1", "TestTable1", "undefined"));
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestTable1"));
+    alterTableDesc.setAlterTableType(AlterTableType.RENAME_COLUMN);
+    catalog.alterTable(alterTableDesc);
+  }
+
+  @Test(expected = DuplicateColumnException.class)
+  public void testAddDuplicateColumn() throws Exception {
+    AlterTableDesc alterTableDesc = new AlterTableDesc();
+    alterTableDesc.setAddColumn(new Column(CatalogUtil.buildFQName("TestDatabase1", "TestTable1", "cOlumn"),
+        CatalogUtil.newSimpleDataType(Type.BLOB)));
+    alterTableDesc.setTableName(CatalogUtil.buildFQName("TestDatabase1", "TestTable1"));
+    alterTableDesc.setAlterTableType(AlterTableType.ADD_COLUMN);
+    catalog.alterTable(alterTableDesc);
+  }
+
+  @Test(expected = DuplicateIndexException.class)
+  public void testCreateDuplicateIndex() throws Exception {
+    TableDesc tableDesc = catalog.getTableDesc("TestDatabase1", "testTable1");
+    SortSpec[] colSpecs = new SortSpec[1];
+    colSpecs[0] = new SortSpec(tableDesc.getSchema().getColumn(0), true, false);
+    catalog.createIndex(
+        new IndexDesc("TestDatabase1", "testTable1",
+            "new_index", new URI("idx_test"), colSpecs,
+            IndexMethod.TWO_LEVEL_BIN_TREE, true, true, tableDesc.getSchema()));
+
+    tableDesc = catalog.getTableDesc("TestDatabase1", "testTable1");
+    colSpecs = new SortSpec[1];
+    colSpecs[0] = new SortSpec(tableDesc.getSchema().getColumn(0), true, false);
+    catalog.createIndex(
+        new IndexDesc("TestDatabase1", "testTable1",
+            "new_index", new URI("idx_test"), colSpecs,
+            IndexMethod.TWO_LEVEL_BIN_TREE, true, true, tableDesc.getSchema()));
+  }
+
+  @Test(expected = UndefinedDatabaseException.class)
+  public void testDropIndexOfUndefinedDatabase() throws Exception {
+    catalog.dropIndex("undefined", "undefined");
+  }
+
+  @Test(expected = UndefinedIndexException.class)
+  public void testDropUndefinedIndex() throws Exception {
+    catalog.dropIndex("TestDatabase1", "undefined");
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestLinkedMetadataManager.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestLinkedMetadataManager.java b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestLinkedMetadataManager.java
index 764ac64..30c563f 100644
--- a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestLinkedMetadataManager.java
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestLinkedMetadataManager.java
@@ -22,15 +22,10 @@ import com.google.common.base.Function;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-import org.apache.hadoop.fs.Path;
-import org.apache.tajo.TajoConstants;
 import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.common.TajoDataTypes.Type;
-import org.apache.tajo.conf.TajoConf;
 import org.apache.tajo.exception.*;
-import org.apache.tajo.util.CommonTestingUtil;
 import org.apache.tajo.util.KeyValueSet;
-import org.apache.tajo.util.Pair;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -41,7 +36,6 @@ import java.net.URI;
 import java.util.Collection;
 import java.util.Collections;
 
-import static org.apache.tajo.TajoConstants.DEFAULT_DATABASE_NAME;
 import static org.junit.Assert.*;
 
 public class TestLinkedMetadataManager {
@@ -150,37 +144,18 @@ public class TestLinkedMetadataManager {
 
   static CatalogServer server;
   static CatalogService catalog;
-  static String testDir;
 
   @BeforeClass
   public static void setUp() throws IOException, DuplicateTablespaceException, DuplicateDatabaseException,
       UnsupportedCatalogStore {
-    TajoConf conf = new TajoConf();
-    conf.setVar(TajoConf.ConfVars.CATALOG_ADDRESS, "127.0.0.1:0");
-
-    Pair<TajoConf, String> confAndTestDir = TestCatalog.newTajoConfForCatalogTest();
-    testDir = confAndTestDir.getSecond();
-
-    server = new CatalogServer(
+    server = new MiniCatalogServer(
         Sets.newHashSet(new MockupMetadataProvider1(), new MockupMetadataProvider2()), Collections.EMPTY_LIST);
-    server.init(confAndTestDir.getFirst());
-    server.start();
     catalog = new LocalCatalogWrapper(server);
-
-    Path defaultTableSpace = CommonTestingUtil.getTestDir();
-
-    if (!catalog.existTablespace(TajoConstants.DEFAULT_TABLESPACE_NAME)) {
-      catalog.createTablespace(TajoConstants.DEFAULT_TABLESPACE_NAME, defaultTableSpace.toUri().toString());
-    }
-    if (!catalog.existDatabase(DEFAULT_DATABASE_NAME)) {
-      catalog.createDatabase(DEFAULT_DATABASE_NAME, TajoConstants.DEFAULT_TABLESPACE_NAME);
-    }
   }
 
   @AfterClass
   public static void tearDown() throws IOException {
     server.stop();
-    CommonTestingUtil.cleanupTestDir(testDir);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java
----------------------------------------------------------------------
diff --git a/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java b/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java
index 8b178a6..680b5ec 100644
--- a/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java
+++ b/tajo-cluster-tests/src/test/java/org/apache/tajo/TajoTestingCluster.java
@@ -71,7 +71,7 @@ public class TajoTestingCluster {
 	private TajoConf conf;
   private FileSystem defaultFS;
   private MiniDFSCluster dfsCluster;
-	private MiniCatalogServer catalogServer;
+	private CatalogServer catalogServer;
   private HBaseTestClusterUtil hbaseUtil;
 
   private TajoMaster tajoMaster;
@@ -292,29 +292,35 @@ public class TajoTestingCluster {
   ////////////////////////////////////////////////////////
   // Catalog Section
   ////////////////////////////////////////////////////////
-  public MiniCatalogServer startCatalogCluster() throws Exception {
+  public CatalogServer startCatalogCluster() throws Exception {
     if(isCatalogServerRunning) throw new IOException("Catalog Cluster already running");
 
     CatalogTestingUtil.configureCatalog(conf, clusterTestBuildDir.getAbsolutePath());
     LOG.info("Apache Derby repository is set to " + conf.get(CatalogConstants.CATALOG_URI));
     conf.setVar(ConfVars.CATALOG_ADDRESS, "localhost:0");
 
-    catalogServer = new MiniCatalogServer(conf);
+    catalogServer = new CatalogServer();
+    catalogServer.init(conf);
+    catalogServer.start();
     isCatalogServerRunning = true;
     return this.catalogServer;
   }
 
   public void shutdownCatalogCluster() {
     if (catalogServer != null) {
-      this.catalogServer.shutdown();
+      this.catalogServer.stop();
     }
     isCatalogServerRunning = false;
   }
 
-  public MiniCatalogServer getMiniCatalogCluster() {
+  public CatalogServer getMiniCatalogCluster() {
     return this.catalogServer;
   }
 
+  public CatalogService getCatalogService() {
+    return new LocalCatalogWrapper(catalogServer);
+  }
+
   public boolean isHiveCatalogStoreRunning() {
     return isHiveCatalogStoreUse;
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java b/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java
index b06cb36..5a75a18 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/ExceptionUtil.java
@@ -58,8 +58,9 @@ public class ExceptionUtil {
     ADD_EXCEPTION(UNDEFINED_PARTITION, UndefinedPartitionException.class);
     ADD_EXCEPTION(UNDEFINED_PARTITION_KEY, UndefinedPartitionKeyException.class);
     ADD_EXCEPTION(UNDEFINED_OPERATOR, UndefinedOperatorException.class);
+    ADD_EXCEPTION(UNDEFINED_INDEX_NAME, UndefinedIndexException.class);
 
-    ADD_EXCEPTION(DUPLICATE_TABLESPACE, DuplicateTableException.class);
+    ADD_EXCEPTION(DUPLICATE_TABLESPACE, DuplicateTablespaceException.class);
     ADD_EXCEPTION(DUPLICATE_DATABASE, DuplicateDatabaseException.class);
     // ADD_EXCEPTION(DUPLICATE_SCHEMA, );
     ADD_EXCEPTION(DUPLICATE_TABLE, DuplicateTableException.class);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
index 754edf4..7c79724 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
@@ -90,7 +90,8 @@ public class ExprTestBase {
   public static void setUp() throws Exception {
     util = new TajoTestingCluster();
     conf = util.getConfiguration();
-    cat = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    cat = util.getCatalogService();
     cat.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234/warehouse");
     cat.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
     Map<FunctionSignature, FunctionDesc> map = FunctionLoader.load();

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
index e10f755..fd8e502 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
@@ -90,7 +90,7 @@ public class TestEvalTreeUtil {
   public static void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.startCatalogCluster();
-    catalog = util.getMiniCatalogCluster().getCatalog();
+    catalog = util.getCatalogService();
     for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) {
       catalog.createFunction(funcDesc);
     }

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestJoinOrderAlgorithm.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestJoinOrderAlgorithm.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestJoinOrderAlgorithm.java
index 3d63471..cf5699f 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestJoinOrderAlgorithm.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestJoinOrderAlgorithm.java
@@ -60,7 +60,7 @@ public class TestJoinOrderAlgorithm {
   public static void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.startCatalogCluster();
-    catalog = util.getMiniCatalogCluster().getCatalog();
+    catalog = util.getCatalogService();
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234/warehouse");
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
     for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java
index c628579..b0c5ad1 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java
@@ -58,7 +58,7 @@ public class TestLogicalOptimizer {
   public static void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.startCatalogCluster();
-    catalog = util.getMiniCatalogCluster().getCatalog();
+    catalog = util.getCatalogService();
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234/warehouse");
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
     for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
index d49c43e..a03ee49 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlan.java
@@ -40,7 +40,7 @@ public class TestLogicalPlan {
   public static void setup() throws Exception {
     util = new TajoTestingCluster();
     util.startCatalogCluster();
-    planner = new LogicalPlanner(util.getMiniCatalogCluster().getCatalog(), TablespaceManager.getInstance());
+    planner = new LogicalPlanner(util.getCatalogService(), TablespaceManager.getInstance());
   }
 
   public static void tearDown() {

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
index 24b86a3..cfb1ed8 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
@@ -77,7 +77,8 @@ public class TestLogicalPlanner {
   @BeforeClass
   public static void setUp() throws Exception {
     util = new TajoTestingCluster();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234");
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestPlannerUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestPlannerUtil.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestPlannerUtil.java
index 44a856a..5d02a7f 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestPlannerUtil.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/TestPlannerUtil.java
@@ -68,7 +68,7 @@ public class TestPlannerUtil {
   public static void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.startCatalogCluster();
-    catalog = util.getMiniCatalogCluster().getCatalog();
+    catalog = util.getCatalogService();
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:1234/warehouse");
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestExternalSortExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestExternalSortExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestExternalSortExec.java
index 515f2a7..e796bad 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestExternalSortExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestExternalSortExec.java
@@ -72,7 +72,8 @@ public class TestExternalSortExec {
   public void setUp() throws Exception {
     this.conf = new TajoConf();
     util = new TajoTestingCluster();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterHashJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterHashJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterHashJoinExec.java
index 477d5f9..2e26a2a 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterHashJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterHashJoinExec.java
@@ -81,7 +81,8 @@ public class TestFullOuterHashJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterMergeJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterMergeJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterMergeJoinExec.java
index 1a71e24..fd42b9a 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterMergeJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestFullOuterMergeJoinExec.java
@@ -84,7 +84,8 @@ public class TestFullOuterMergeJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashAntiJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashAntiJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashAntiJoinExec.java
index 5c99e63..103d2b1 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashAntiJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashAntiJoinExec.java
@@ -71,7 +71,8 @@ public class TestHashAntiJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashJoinExec.java
index 9be3380..a4afa7f 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashJoinExec.java
@@ -73,7 +73,8 @@ public class TestHashJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashSemiJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashSemiJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashSemiJoinExec.java
index 73648b4..f99dc9e 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashSemiJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestHashSemiJoinExec.java
@@ -71,7 +71,8 @@ public class TestHashSemiJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestLeftOuterHashJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestLeftOuterHashJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestLeftOuterHashJoinExec.java
index 63854ad..ab5f509 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestLeftOuterHashJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestLeftOuterHashJoinExec.java
@@ -79,7 +79,8 @@ public class TestLeftOuterHashJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestMergeJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestMergeJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestMergeJoinExec.java
index 915fce6..d297825 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestMergeJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestMergeJoinExec.java
@@ -71,7 +71,8 @@ public class TestMergeJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     Path testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(TajoConstants.DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestPhysicalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestPhysicalPlanner.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestPhysicalPlanner.java
index adc2f27..0b94c52 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestPhysicalPlanner.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestPhysicalPlanner.java
@@ -99,7 +99,7 @@ public class TestPhysicalPlanner {
     conf = util.getConfiguration();
     testDir = CommonTestingUtil.getTestDir(TajoTestingCluster.DEFAULT_TEST_DIRECTORY + "/TestPhysicalPlanner");
     sm = TablespaceManager.getLocalFs();
-    catalog = util.getMiniCatalogCluster().getCatalog();
+    catalog = util.getCatalogService();
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
     for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestProgressExternalSortExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestProgressExternalSortExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestProgressExternalSortExec.java
index f916b82..ec41b0d 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestProgressExternalSortExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestProgressExternalSortExec.java
@@ -75,7 +75,8 @@ public class TestProgressExternalSortExec {
   public void setUp() throws Exception {
     this.conf = new TajoConf();
     util = new TajoTestingCluster();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterHashJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterHashJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterHashJoinExec.java
index f3e8eb6..9a7eaff 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterHashJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterHashJoinExec.java
@@ -73,7 +73,8 @@ public class TestRightOuterHashJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterMergeJoinExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterMergeJoinExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterMergeJoinExec.java
index 0744f97..280722b 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterMergeJoinExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestRightOuterMergeJoinExec.java
@@ -84,7 +84,8 @@ public class TestRightOuterMergeJoinExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestSortIntersectExec.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestSortIntersectExec.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestSortIntersectExec.java
index 380f91f..66d38b7 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestSortIntersectExec.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/planner/physical/TestSortIntersectExec.java
@@ -77,7 +77,8 @@ public class TestSortIntersectExec {
   public void setUp() throws Exception {
     util = new TajoTestingCluster();
     util.initTestDir();
-    catalog = util.startCatalogCluster().getCatalog();
+    util.startCatalogCluster();
+    catalog = util.getCatalogService();
     testDir = CommonTestingUtil.getTestDir(TEST_PATH);
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString());
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core-tests/src/test/java/org/apache/tajo/master/TestExecutionBlockCursor.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/master/TestExecutionBlockCursor.java b/tajo-core-tests/src/test/java/org/apache/tajo/master/TestExecutionBlockCursor.java
index aa1bbd8..578b278 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/master/TestExecutionBlockCursor.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/master/TestExecutionBlockCursor.java
@@ -62,7 +62,7 @@ public class TestExecutionBlockCursor {
     conf = util.getConfiguration();
     conf.set(TajoConf.ConfVars.$TEST_BROADCAST_JOIN_ENABLED.varname, "false");
 
-    catalog = util.getMiniCatalogCluster().getCatalog();
+    catalog = util.getCatalogService();
     catalog.createTablespace(DEFAULT_TABLESPACE_NAME, "hdfs://localhost:!234/warehouse");
     catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME);
     TPCH tpch = new TPCH();

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java b/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java
index abbab50..9f80802 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/exec/DDLExecutor.java
@@ -128,7 +128,7 @@ public class DDLExecutor {
   }
 
   public void createIndex(final QueryContext queryContext, final CreateIndexNode createIndexNode)
-      throws DuplicateIndexException {
+      throws DuplicateIndexException, UndefinedTableException, UndefinedDatabaseException {
 
     String databaseName, simpleIndexName, qualifiedIndexName;
     if (CatalogUtil.isFQTableName(createIndexNode.getIndexName())) {
@@ -155,17 +155,12 @@ public class DDLExecutor {
         simpleIndexName, createIndexNode.getIndexPath(),
         createIndexNode.getKeySortSpecs(), createIndexNode.getIndexMethod(),
         createIndexNode.isUnique(), false, scanNode.getLogicalSchema());
-
-    if (catalog.createIndex(indexDesc)) {
-      LOG.info("Index " + qualifiedIndexName + " is created for the table " + scanNode.getTableName() + ".");
-    } else {
-      LOG.info("Index creation " + qualifiedIndexName + " is failed.");
-      throw new TajoInternalError("Cannot create index \"" + qualifiedIndexName + "\".");
-    }
+    catalog.createIndex(indexDesc);
+    LOG.info("Index " + qualifiedIndexName + " is created for the table " + scanNode.getTableName() + ".");
   }
 
   public void dropIndex(final QueryContext queryContext, final DropIndexNode dropIndexNode)
-      throws UndefinedIndexException {
+      throws UndefinedIndexException, UndefinedDatabaseException {
 
     String databaseName, simpleIndexName;
     if (CatalogUtil.isFQTableName(dropIndexNode.getIndexName())) {
@@ -182,11 +177,7 @@ public class DDLExecutor {
     }
 
     IndexDesc desc = catalog.getIndexByName(databaseName, simpleIndexName);
-
-    if (!catalog.dropIndex(databaseName, simpleIndexName)) {
-      LOG.info("Cannot drop index \"" + simpleIndexName + "\".");
-      throw new TajoInternalError("Cannot drop index \"" + simpleIndexName + "\".");
-    }
+    catalog.dropIndex(databaseName, simpleIndexName);
 
     Path indexPath = new Path(desc.getIndexPath());
     try {

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java b/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java
index 8bb3845..1ec45d1 100644
--- a/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java
+++ b/tajo-core/src/main/java/org/apache/tajo/querymaster/Query.java
@@ -598,12 +598,8 @@ public class Query implements EventHandler<QueryEvent> {
             simpleIndexName, createIndexNode.getIndexPath(),
             createIndexNode.getKeySortSpecs(), createIndexNode.getIndexMethod(),
             createIndexNode.isUnique(), false, scanNode.getLogicalSchema());
-        if (catalog.createIndex(indexDesc)) {
-          LOG.info("Index " + qualifiedIndexName + " is created for the table " + scanNode.getTableName() + ".");
-        } else {
-          LOG.info("Index creation " + qualifiedIndexName + " is failed.");
-          throw new TajoInternalError("Cannot create index \"" + qualifiedIndexName + "\".");
-        }
+        catalog.createIndex(indexDesc);
+        LOG.info("Index " + qualifiedIndexName + " is created for the table " + scanNode.getTableName() + ".");
       }
     }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/7d97284a/tajo-jdbc/src/test/java/org/apache/tajo/jdbc/TestTajoJdbcNegative.java
----------------------------------------------------------------------
diff --git a/tajo-jdbc/src/test/java/org/apache/tajo/jdbc/TestTajoJdbcNegative.java b/tajo-jdbc/src/test/java/org/apache/tajo/jdbc/TestTajoJdbcNegative.java
index c1414dc..8f84226 100644
--- a/tajo-jdbc/src/test/java/org/apache/tajo/jdbc/TestTajoJdbcNegative.java
+++ b/tajo-jdbc/src/test/java/org/apache/tajo/jdbc/TestTajoJdbcNegative.java
@@ -77,7 +77,6 @@ public class TestTajoJdbcNegative extends QueryTestCaseBase {
       fail("Must be failed.");
     } catch (SQLException s) {
       assertEquals(toSQLState(ResultCode.CLIENT_CONNECTION_EXCEPTION), s.getSQLState());
-      assertEquals("Connection refused: localhost/127.0.0.1:" + port, s.getMessage());
     }
   }
 


Mime
View raw message