tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [37/52] [abbrv] tajo git commit: TAJO-1691: Refactor visitors and planner to throw TajoException.
Date Wed, 22 Jul 2015 13:01:10 GMT
TAJO-1691: Refactor visitors and planner to throw TajoException.

Closes #637


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

Branch: refs/heads/index_support
Commit: 4841c656ff06dbab76ca59240623f956da2f4177
Parents: c50a5da
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Wed Jul 22 12:35:45 2015 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Wed Jul 22 12:35:45 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |   2 +
 .../org/apache/tajo/catalog/CatalogUtil.java    |   7 +-
 .../exception/AmbiguousTableException.java      |  30 ++++
 .../exception/AmbiguousColumnException.java     |  32 ++++
 .../apache/tajo/exception/ErrorMessages.java    |   3 +
 .../tajo/exception/TajoInternalError.java       |   4 +
 .../tajo/exception/TajoRuntimeException.java    |   5 +
 .../engine/codegen/ExecutorPreCompiler.java     |  28 ++--
 .../engine/planner/global/GlobalPlanner.java    |  69 ++++----
 .../global/builder/DistinctGroupbyBuilder.java  |  11 +-
 .../rewriter/GlobalPlanRewriteEngine.java       |   4 +-
 .../global/rewriter/GlobalPlanRewriteRule.java  |   3 +-
 .../rewriter/rules/BroadcastJoinRule.java       |   3 +-
 .../utils/test/ErrorInjectionRewriter.java      |   3 +-
 .../exec/ExplainPlanPreprocessorForTest.java    |  13 +-
 .../NonForwardQueryResultSystemScanner.java     |   6 +-
 .../worker/ExecutionBlockSharedResource.java    |   4 +-
 .../java/org/apache/tajo/QueryTestCaseBase.java |  42 +++--
 .../apache/tajo/engine/eval/ExprTestBase.java   |  10 +-
 .../tajo/engine/eval/TestEvalTreeUtil.java      |  36 ++---
 .../engine/planner/TestLogicalOptimizer.java    |  50 +++---
 .../tajo/engine/planner/TestLogicalPlanner.java |  79 +++++-----
 .../tajo/engine/planner/TestPlannerUtil.java    |   4 +-
 .../engine/planner/TestQueryValidation.java     |   8 +-
 .../planner/physical/TestBNLJoinExec.java       |  13 +-
 .../planner/physical/TestExternalSortExec.java  |   9 +-
 .../physical/TestFullOuterHashJoinExec.java     |  22 +--
 .../physical/TestFullOuterMergeJoinExec.java    |  19 ++-
 .../planner/physical/TestHashAntiJoinExec.java  |   9 +-
 .../planner/physical/TestHashJoinExec.java      |  13 +-
 .../planner/physical/TestHashSemiJoinExec.java  |   4 +-
 .../physical/TestLeftOuterHashJoinExec.java     |  19 +--
 .../planner/physical/TestMergeJoinExec.java     |   4 +-
 .../engine/planner/physical/TestNLJoinExec.java |  10 +-
 .../planner/physical/TestPhysicalPlanner.java   |  48 +++---
 .../physical/TestRightOuterHashJoinExec.java    |   8 +-
 .../physical/TestRightOuterMergeJoinExec.java   |  26 +--
 .../engine/planner/physical/TestSortExec.java   |  14 +-
 .../planner/physical/TestSortIntersectExec.java |   7 +-
 .../org/apache/tajo/plan/ExprAnnotator.java     | 138 ++++++++--------
 .../org/apache/tajo/plan/ExprNormalizer.java    |  21 +--
 .../org/apache/tajo/plan/LogicalOptimizer.java  |  37 ++---
 .../java/org/apache/tajo/plan/LogicalPlan.java  |  16 +-
 .../tajo/plan/LogicalPlanPreprocessor.java      |  59 +++----
 .../org/apache/tajo/plan/LogicalPlanner.java    | 157 ++++++++++---------
 .../org/apache/tajo/plan/NamedExprsManager.java |  10 +-
 .../org/apache/tajo/plan/TypeDeterminant.java   |  40 ++---
 .../tajo/plan/algebra/AlgebraVisitor.java       | 134 ++++++++--------
 .../plan/algebra/AmbiguousFieldException.java   |  32 ----
 .../tajo/plan/algebra/BaseAlgebraVisitor.java   | 146 ++++++++---------
 .../GreedyHeuristicJoinOrderAlgorithm.java      |  10 +-
 .../apache/tajo/plan/joinorder/JoinGraph.java   |   2 +-
 .../tajo/plan/joinorder/JoinOrderAlgorithm.java |   3 +-
 .../tajo/plan/nameresolver/NameResolver.java    |  46 +++---
 .../plan/nameresolver/ResolverByLegacy.java     |   8 +-
 .../tajo/plan/nameresolver/ResolverByRels.java  |   3 +-
 .../nameresolver/ResolverByRelsAndSubExprs.java |   3 +-
 .../nameresolver/ResolverBySubExprsAndRels.java |   3 +-
 .../rewrite/BaseLogicalPlanRewriteEngine.java   |   4 +-
 .../plan/rewrite/LogicalPlanRewriteEngine.java  |   4 +-
 .../plan/rewrite/LogicalPlanRewriteRule.java    |   3 +-
 .../plan/rewrite/rules/FilterPushDownRule.java  |  60 +++----
 .../rules/LogicalPlanEqualityTester.java        |   4 +-
 .../rewrite/rules/PartitionedTableRewriter.java |  17 +-
 .../rewrite/rules/ProjectionPushDownRule.java   |  59 +++----
 .../tajo/plan/serder/LogicalNodeSerializer.java |  53 ++++---
 .../org/apache/tajo/plan/util/ExprFinder.java   |   8 +-
 .../org/apache/tajo/plan/util/PlannerUtil.java  |  44 ++----
 .../tajo/plan/verifier/ExprsVerifier.java       |   3 +-
 .../tajo/plan/verifier/LogicalPlanVerifier.java |  44 +++---
 .../plan/verifier/PreLogicalPlanVerifier.java   |  34 ++--
 .../plan/visitor/BasicLogicalPlanVisitor.java   |  63 ++++----
 .../plan/visitor/ExplainLogicalPlanVisitor.java |  47 +++---
 .../tajo/plan/visitor/LogicalPlanVisitor.java   |  55 +++----
 .../tajo/plan/visitor/SimpleAlgebraVisitor.java |  57 +++----
 .../org/apache/tajo/storage/Tablespace.java     |   6 +-
 .../tajo/storage/hbase/HBaseTablespace.java     |   4 +-
 .../storage/hbase/SortedInsertRewriter.java     |   9 +-
 78 files changed, 1116 insertions(+), 1011 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 36cd9fc..c0a5e38 100644
--- a/CHANGES
+++ b/CHANGES
@@ -384,6 +384,8 @@ Release 0.11.0 - unreleased
 
   SUB TASKS
 
+    TAJO-1691: Refactor visitors and planner to throw TajoException. (hyunsik)
+
     TAJO-1525: Implement INTERSECT [ALL] physical operator. (Contributed 
     Keuntae Park, Committed by hyunsik) 
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
index 87bd972..b668d05 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/CatalogUtil.java
@@ -26,13 +26,15 @@ import org.apache.tajo.TajoConstants;
 import org.apache.tajo.catalog.partition.PartitionDesc;
 import org.apache.tajo.catalog.partition.PartitionMethodDesc;
 import org.apache.tajo.catalog.proto.CatalogProtos;
+import org.apache.tajo.catalog.proto.CatalogProtos.PartitionKeyProto;
 import org.apache.tajo.catalog.proto.CatalogProtos.SchemaProto;
 import org.apache.tajo.catalog.proto.CatalogProtos.TableDescProto;
 import org.apache.tajo.catalog.proto.CatalogProtos.TableIdentifierProto;
-import org.apache.tajo.catalog.proto.CatalogProtos.PartitionKeyProto;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.exception.InvalidOperationException;
+import org.apache.tajo.exception.TajoRuntimeException;
+import org.apache.tajo.exception.UndefinedOperatorException;
 import org.apache.tajo.storage.StorageConstants;
 import org.apache.tajo.util.KeyValueSet;
 import org.apache.tajo.util.Pair;
@@ -683,8 +685,7 @@ public class CatalogUtil {
       if (types[i].getType() != Type.NULL_TYPE) {
         Type candidate = TUtil.getFromNestedMap(OPERATION_CASTING_MAP, widest.getType(), types[i].getType());
         if (candidate == null) {
-          throw new InvalidOperationException("No matched operation for those types: " + StringUtils.join
-              (types));
+          throw new TajoRuntimeException(new UndefinedOperatorException(StringUtils.join(types)));
         }
         widest = newSimpleDataType(candidate);
       }

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/AmbiguousTableException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/AmbiguousTableException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/AmbiguousTableException.java
new file mode 100644
index 0000000..65ff746
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/AmbiguousTableException.java
@@ -0,0 +1,30 @@
+/**
+ * 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.exception;
+
+import org.apache.tajo.common.TajoDataTypes.DataType;
+import org.apache.tajo.error.Errors;
+
+import static org.apache.tajo.function.FunctionUtil.buildSimpleFunctionSignature;
+
+public class AmbiguousTableException extends CatalogException {
+  public AmbiguousTableException(String tableName) {
+    super(Errors.ResultCode.AMBIGUOUS_TABLE, tableName);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousColumnException.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousColumnException.java b/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousColumnException.java
new file mode 100644
index 0000000..7cf6e1e
--- /dev/null
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/AmbiguousColumnException.java
@@ -0,0 +1,32 @@
+/**
+ * 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.exception;
+
+import static org.apache.tajo.error.Errors.ResultCode.AMBIGUOUS_COLUMN;
+
+public class AmbiguousColumnException extends TajoException {
+  private static final long serialVersionUID = 3102675985226352347L;
+
+  /**
+   * @param fieldName
+   */
+  public AmbiguousColumnException(String fieldName) {
+    super(AMBIGUOUS_COLUMN, fieldName);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java b/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java
index b051eb5..088fb91 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/ErrorMessages.java
@@ -74,6 +74,9 @@ public class ErrorMessages {
     ADD_MESSAGE(DUPLICATE_INDEX, "index '%s' already exists", 1);
     ADD_MESSAGE(DUPLICATE_PARTITION, "partition for '%s' already exists", 1);
 
+    ADD_MESSAGE(AMBIGUOUS_TABLE, "table name '%s' is ambiguous", 1);
+    ADD_MESSAGE(AMBIGUOUS_COLUMN, "column name '%s' is ambiguous", 1);
+
     ADD_MESSAGE(DIVISION_BY_ZERO, "Division by zero: %s", 1);
 
     ADD_MESSAGE(DATATYPE_MISMATCH,

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java b/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java
index 5ffa26d..767c13c 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/TajoInternalError.java
@@ -32,4 +32,8 @@ public class TajoInternalError extends TajoError {
   public TajoInternalError(Throwable t) {
     super(ResultCode.INTERNAL_ERROR, t.getMessage());
   }
+
+  public TajoInternalError(TajoException t) {
+    super(t.getErrorCode(), t.getMessage());
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java b/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java
index dfde534..69da2a8 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/TajoRuntimeException.java
@@ -44,6 +44,11 @@ public class TajoRuntimeException extends RuntimeException implements TajoExcept
     this.code = code;
   }
 
+  public TajoRuntimeException(TajoException e) {
+    super(e.getMessage());
+    this.code = e.getErrorCode();
+  }
+
   @Override
   public ResultCode getErrorCode() {
     return code;

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ExecutorPreCompiler.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ExecutorPreCompiler.java b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ExecutorPreCompiler.java
index e472ee1..87d33de 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ExecutorPreCompiler.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ExecutorPreCompiler.java
@@ -22,12 +22,12 @@ import com.google.common.collect.Maps;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.tajo.catalog.Schema;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.plan.LogicalPlan;
-import org.apache.tajo.plan.util.PlannerUtil;
-import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.Target;
 import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.plan.logical.*;
+import org.apache.tajo.plan.util.PlannerUtil;
 import org.apache.tajo.plan.visitor.BasicLogicalPlanVisitor;
 import org.apache.tajo.util.Pair;
 
@@ -44,13 +44,13 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
     instance = new ExecutorPreCompiler();
   }
 
-  public static void compile(CompilationContext context, LogicalNode node) throws PlanningException {
+  public static void compile(CompilationContext context, LogicalNode node) throws TajoException {
     instance.visit(context, null, null, node, new Stack<LogicalNode>());
     context.compiledEval = Collections.unmodifiableMap(context.compiledEval);
   }
 
   public static Map<Pair<Schema, EvalNode>, EvalNode> compile(TajoClassLoader classLoader, LogicalNode node)
-      throws PlanningException {
+      throws TajoException {
     CompilationContext context = new CompilationContext(classLoader);
     instance.visit(context, null, null, node, new Stack<LogicalNode>());
     return context.compiledEval;
@@ -111,7 +111,7 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
 
   @Override
   public LogicalNode visitProjection(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                     ProjectionNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                     ProjectionNode node, Stack<LogicalNode> stack) throws TajoException {
     super.visitProjection(context, plan, block, node, stack);
 
     compileProjectableNode(context, node.getInSchema(), node);
@@ -121,7 +121,7 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
 
   @Override
   public LogicalNode visitHaving(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                 HavingNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                 HavingNode node, Stack<LogicalNode> stack) throws TajoException {
     super.visitHaving(context, plan, block, node, stack);
 
     compileSelectableNode(context, node.getInSchema(), node);
@@ -131,7 +131,7 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
 
   @Override
   public LogicalNode visitGroupBy(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                  GroupbyNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                  GroupbyNode node, Stack<LogicalNode> stack) throws TajoException {
     super.visitGroupBy(context, plan, block, node, stack);
 
     compileProjectableNode(context, node.getInSchema(), node);
@@ -141,7 +141,7 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
 
   @Override
   public LogicalNode visitWindowAgg(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                    WindowAggNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                    WindowAggNode node, Stack<LogicalNode> stack) throws TajoException {
     super.visitWindowAgg(context, plan, block, node, stack);
 
     compileProjectableNode(context, node.getInSchema(), node);
@@ -150,7 +150,7 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
   }
 
   public LogicalNode visitDistinctGroupby(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                          DistinctGroupbyNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                          DistinctGroupbyNode node, Stack<LogicalNode> stack) throws TajoException {
     super.visitDistinctGroupby(context, plan, block, node, stack);
 
     compileProjectableNode(context, node.getInSchema(), node);
@@ -159,7 +159,7 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
 
   @Override
   public LogicalNode visitFilter(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                 SelectionNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                 SelectionNode node, Stack<LogicalNode> stack) throws TajoException {
     super.visitFilter(context, plan, block, node, stack);
 
     compileSelectableNode(context, node.getInSchema(), node);
@@ -169,7 +169,7 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
 
   @Override
   public LogicalNode visitJoin(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                               JoinNode node, Stack<LogicalNode> stack) throws PlanningException {
+                               JoinNode node, Stack<LogicalNode> stack) throws TajoException {
     super.visitJoin(context, plan, block, node, stack);
 
     compileProjectableNode(context, node.getInSchema(), node);
@@ -183,7 +183,7 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
 
   @Override
   public LogicalNode visitTableSubQuery(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                   TableSubQueryNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                   TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException {
     stack.push(node);
     visit(context, plan, null, node.getSubQuery(), stack);
     stack.pop();
@@ -200,14 +200,14 @@ public class ExecutorPreCompiler extends BasicLogicalPlanVisitor<ExecutorPreComp
   @Override
   public LogicalNode visitPartitionedTableScan(CompilationContext context, LogicalPlan plan,
                                                LogicalPlan.QueryBlock block, PartitionedTableScanNode node,
-                                               Stack<LogicalNode> stack) throws PlanningException {
+                                               Stack<LogicalNode> stack) throws TajoException {
     visitScan(context, plan, block, node, stack);
     return node;
   }
 
   @Override
   public LogicalNode visitScan(CompilationContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                               ScanNode node, Stack<LogicalNode> stack) throws PlanningException {
+                               ScanNode node, Stack<LogicalNode> stack) throws TajoException {
 
     compileProjectableNode(context, node.getInSchema(), node);
     compileSelectableNode(context, node.getInSchema(), node);

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
index ba4833b..8c63ffd 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/GlobalPlanner.java
@@ -23,10 +23,8 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.fs.Path;
 import org.apache.tajo.ExecutionBlockId;
 import org.apache.tajo.SessionVars;
 import org.apache.tajo.algebra.JoinType;
@@ -40,6 +38,9 @@ import org.apache.tajo.engine.planner.global.rewriter.GlobalPlanRewriteEngine;
 import org.apache.tajo.engine.planner.global.rewriter.GlobalPlanRewriteRuleProvider;
 import org.apache.tajo.engine.query.QueryContext;
 import org.apache.tajo.exception.InternalException;
+import org.apache.tajo.exception.TajoException;
+import org.apache.tajo.exception.TajoInternalError;
+import org.apache.tajo.exception.UnimplementedException;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.Target;
@@ -118,7 +119,7 @@ public class GlobalPlanner {
   /**
    * Builds a master plan from the given logical plan.
    */
-  public void build(QueryContext queryContext, MasterPlan masterPlan) throws IOException, PlanningException {
+  public void build(QueryContext queryContext, MasterPlan masterPlan) throws IOException, TajoException {
 
     DistributedPlannerVisitor planner = new DistributedPlannerVisitor();
     GlobalPlanContext globalPlanContext = new GlobalPlanContext();
@@ -198,8 +199,7 @@ public class GlobalPlanner {
   }
 
   private ExecutionBlock buildJoinPlan(GlobalPlanContext context, JoinNode joinNode,
-                                        ExecutionBlock leftBlock, ExecutionBlock rightBlock)
-      throws PlanningException {
+                                        ExecutionBlock leftBlock, ExecutionBlock rightBlock) {
     MasterPlan masterPlan = context.plan;
     ExecutionBlock currentBlock;
 
@@ -604,7 +604,7 @@ public class GlobalPlanner {
   }
 
   private ExecutionBlock buildGroupBy(GlobalPlanContext context, ExecutionBlock lastBlock,
-                                      GroupbyNode groupbyNode) throws PlanningException {
+                                      GroupbyNode groupbyNode) {
     MasterPlan masterPlan = context.plan;
     ExecutionBlock currentBlock;
 
@@ -842,7 +842,7 @@ public class GlobalPlanner {
    */
   private ExecutionBlock buildStorePlan(GlobalPlanContext context,
                                         ExecutionBlock lastBlock,
-                                        StoreTableNode currentNode) throws PlanningException {
+                                        StoreTableNode currentNode) throws TajoException {
 
 
     if(currentNode.hasPartition()) { // if a target table is a partitioned table
@@ -850,8 +850,7 @@ public class GlobalPlanner {
       // Verify supported partition types
       PartitionMethodDesc partitionMethod = currentNode.getPartitionMethod();
       if (partitionMethod.getPartitionType() != CatalogProtos.PartitionType.COLUMN) {
-        throw new PlanningException(String.format("Not supported partitionsType :%s",
-            partitionMethod.getPartitionType()));
+        throw new UnimplementedException("partition type '" + partitionMethod.getPartitionType().name() + "'");
       }
 
       if (hasUnionChild(currentNode)) { // if it has union children
@@ -884,8 +883,7 @@ public class GlobalPlanner {
    */
   private ExecutionBlock buildShuffleAndStorePlanToPartitionedTableWithUnion(GlobalPlanContext context,
                                                                              StoreTableNode currentNode,
-                                                                             ExecutionBlock lastBlock)
-      throws PlanningException {
+                                                                             ExecutionBlock lastBlock) {
 
     MasterPlan masterPlan = context.plan;
     DataChannel lastChannel = null;
@@ -909,8 +907,7 @@ public class GlobalPlanner {
    */
   private ExecutionBlock buildShuffleAndStorePlanToPartitionedTable(GlobalPlanContext context,
                                                                     StoreTableNode currentNode,
-                                                                    ExecutionBlock lastBlock)
-      throws PlanningException {
+                                                                    ExecutionBlock lastBlock) {
     MasterPlan masterPlan = context.plan;
 
     ExecutionBlock nextBlock = masterPlan.newExecutionBlock();
@@ -980,13 +977,13 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitRoot(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                 LogicalRootNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                 LogicalRootNode node, Stack<LogicalNode> stack) throws TajoException {
       return super.visitRoot(context, plan, block, node, stack);
     }
 
     @Override
     public LogicalNode visitProjection(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                       ProjectionNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                       ProjectionNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitProjection(context, plan, block, node, stack);
 
       ExecutionBlock execBlock = context.execBlockMap.remove(child.getPID());
@@ -1017,7 +1014,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitLimit(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                  LimitNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                  LimitNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitLimit(context, plan, block, node, stack);
 
       ExecutionBlock execBlock;
@@ -1058,7 +1055,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitSort(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                 SortNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                 SortNode node, Stack<LogicalNode> stack) throws TajoException {
 
       LogicalNode child = super.visitSort(context, plan, block, node, stack);
 
@@ -1071,7 +1068,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitHaving(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                    HavingNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                    HavingNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitHaving(context, plan, block, node, stack);
 
       // Don't separate execution block. Having is pushed to the second grouping execution block.
@@ -1085,7 +1082,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitWindowAgg(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                    WindowAggNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                    WindowAggNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitWindowAgg(context, plan, block, node, stack);
 
       ExecutionBlock childBlock = context.execBlockMap.remove(child.getPID());
@@ -1096,7 +1093,7 @@ public class GlobalPlanner {
     }
 
     private ExecutionBlock buildWindowAgg(GlobalPlanContext context, ExecutionBlock lastBlock,
-                                        WindowAggNode windowAgg) throws PlanningException {
+                                        WindowAggNode windowAgg) throws TajoException {
       MasterPlan masterPlan = context.plan;
 
       ExecutionBlock childBlock = lastBlock;
@@ -1138,7 +1135,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitGroupBy(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                    GroupbyNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                    GroupbyNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitGroupBy(context, plan, block, node, stack);
 
       ExecutionBlock childBlock = context.execBlockMap.remove(child.getPID());
@@ -1150,7 +1147,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitFilter(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                   SelectionNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                   SelectionNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitFilter(context, plan, block, node, stack);
 
       ExecutionBlock execBlock = context.execBlockMap.remove(child.getPID());
@@ -1164,7 +1161,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitJoin(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                 JoinNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                 JoinNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode leftChild = visit(context, plan, block, node.getLeftChild(), stack);
       ExecutionBlock leftChildBlock = context.execBlockMap.get(leftChild.getPID());
 
@@ -1192,7 +1189,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitUnion(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock,
-                                  UnionNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                  UnionNode node, Stack<LogicalNode> stack) throws TajoException {
       stack.push(node);
       LogicalPlan.QueryBlock leftQueryBlock = plan.getBlock(node.getLeftChild());
       LogicalNode leftChild = visit(context, plan, leftQueryBlock, leftQueryBlock.getRoot(), stack);
@@ -1262,14 +1259,14 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitExcept(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock,
-                                   ExceptNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                   ExceptNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitExcept(context, plan, queryBlock, node, stack);
       return handleUnaryNode(context, child, node);
     }
 
     @Override
     public LogicalNode visitIntersect(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock,
-                                      IntersectNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                      IntersectNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitIntersect(context, plan, queryBlock, node, stack);
       return handleUnaryNode(context, child, node);
     }
@@ -1277,7 +1274,7 @@ public class GlobalPlanner {
     @Override
     public LogicalNode visitTableSubQuery(GlobalPlanContext context, LogicalPlan plan,
                                           LogicalPlan.QueryBlock queryBlock,
-                                          TableSubQueryNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                          TableSubQueryNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitTableSubQuery(context, plan, queryBlock, node, stack);
       node.setSubQuery(child);
 
@@ -1309,7 +1306,7 @@ public class GlobalPlanner {
           int[] targetMappings = new int[targets.length];
           for (int i = 0; i < targets.length; i++) {
             if (targets[i].getEvalTree().getType() != EvalType.FIELD) {
-              throw new PlanningException("Target of a UnionNode's subquery should be FieldEval.");
+              throw new TajoInternalError("Target of a UnionNode's subquery should be FieldEval.");
             }
             int index = leftMostSubQueryNode.getInSchema().getColumnId(targets[i].getNamedColumn().getQualifiedName());
             if (index < 0) {
@@ -1319,7 +1316,7 @@ public class GlobalPlanner {
               index = leftMostSubQueryNode.getInSchema().getColumnId(column.getQualifiedName());
             }
             if (index < 0) {
-              throw new PlanningException("Can't find matched Target in UnionNode's input schema: " + targets[i]
+              throw new TajoInternalError("Can't find matched Target in UnionNode's input schema: " + targets[i]
                   + "->" + leftMostSubQueryNode.getInSchema());
             }
             targetMappings[i] = index;
@@ -1331,14 +1328,14 @@ public class GlobalPlanner {
             }
             Target[] eachNodeTargets = eachNode.getTargets();
             if (eachNodeTargets.length != targetMappings.length) {
-              throw new PlanningException("Union query can't have different number of target columns.");
+              throw new TajoInternalError("Union query can't have different number of target columns.");
             }
             for (int i = 0; i < eachNodeTargets.length; i++) {
               Column inColumn = eachNode.getInSchema().getColumn(targetMappings[i]);
               eachNodeTargets[i].setAlias(eachNodeTargets[i].getNamedColumn().getQualifiedName());
               EvalNode evalNode = eachNodeTargets[i].getEvalTree();
               if (evalNode.getType() != EvalType.FIELD) {
-                throw new PlanningException("Target of a UnionNode's subquery should be FieldEval.");
+                throw new TajoInternalError("Target of a UnionNode's subquery should be FieldEval.");
               }
               FieldEval fieldEval = (FieldEval) evalNode;
               EvalTreeUtil.changeColumnRef(fieldEval,
@@ -1357,7 +1354,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitScan(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock,
-                                 ScanNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                 ScanNode node, Stack<LogicalNode> stack) throws TajoException {
       ExecutionBlock newExecBlock = context.plan.newExecutionBlock();
       newExecBlock.setPlan(node);
       context.execBlockMap.put(node.getPID(), newExecBlock);
@@ -1367,7 +1364,7 @@ public class GlobalPlanner {
     @Override
     public LogicalNode visitPartitionedTableScan(GlobalPlanContext context, LogicalPlan plan,
                                                  LogicalPlan.QueryBlock block, PartitionedTableScanNode node,
-                                                 Stack<LogicalNode> stack)throws PlanningException {
+                                                 Stack<LogicalNode> stack)throws TajoException {
       ExecutionBlock newExecBlock = context.plan.newExecutionBlock();
       newExecBlock.setPlan(node);
       context.execBlockMap.put(node.getPID(), newExecBlock);
@@ -1376,7 +1373,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitStoreTable(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock,
-                                       StoreTableNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                       StoreTableNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitStoreTable(context, plan, queryBlock, node, stack);
 
       ExecutionBlock childBlock = context.execBlockMap.remove(child.getPID());
@@ -1388,7 +1385,7 @@ public class GlobalPlanner {
 
     @Override
     public LogicalNode visitCreateTable(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock,
-                                       CreateTableNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                       CreateTableNode node, Stack<LogicalNode> stack) throws TajoException {
       LogicalNode child = super.visitStoreTable(context, plan, queryBlock, node, stack);
 
       ExecutionBlock childBlock = context.execBlockMap.remove(child.getPID());
@@ -1401,7 +1398,7 @@ public class GlobalPlanner {
     @Override
     public LogicalNode visitInsert(GlobalPlanContext context, LogicalPlan plan, LogicalPlan.QueryBlock queryBlock,
                                    InsertNode node, Stack<LogicalNode> stack)
-        throws PlanningException {
+        throws TajoException {
       LogicalNode child = super.visitInsert(context, plan, queryBlock, node, stack);
 
       ExecutionBlock childBlock = context.execBlockMap.remove(child.getPID());

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java
index f181193..2c88fdb 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/builder/DistinctGroupbyBuilder.java
@@ -30,6 +30,7 @@ import org.apache.tajo.engine.planner.global.ExecutionBlock;
 import org.apache.tajo.engine.planner.global.GlobalPlanner;
 import org.apache.tajo.engine.planner.global.GlobalPlanner.GlobalPlanContext;
 import org.apache.tajo.engine.planner.global.MasterPlan;
+import org.apache.tajo.exception.TajoInternalError;
 import org.apache.tajo.plan.serder.PlanProto.DistinctGroupbyEnforcer.DistinctAggregationAlgorithm;
 import org.apache.tajo.plan.serder.PlanProto.DistinctGroupbyEnforcer.MultipleAggregationStage;
 import org.apache.tajo.plan.serder.PlanProto.DistinctGroupbyEnforcer.SortSpecArray;
@@ -61,7 +62,7 @@ public class DistinctGroupbyBuilder {
 
   public ExecutionBlock buildMultiLevelPlan(GlobalPlanContext context,
                                             ExecutionBlock latestExecBlock,
-                                            LogicalNode currentNode) throws PlanningException {
+                                            LogicalNode currentNode) {
     try {
       GroupbyNode groupbyNode = (GroupbyNode) currentNode;
 
@@ -177,8 +178,7 @@ public class DistinctGroupbyBuilder {
 
       return thirdStageBlock;
     } catch (Exception e) {
-      LOG.error(e.getMessage(), e);
-      throw new PlanningException(e);
+      throw new TajoInternalError(e);
     }
   }
 
@@ -303,7 +303,7 @@ public class DistinctGroupbyBuilder {
 
   public ExecutionBlock buildPlan(GlobalPlanContext context,
                                   ExecutionBlock latestExecBlock,
-                                  LogicalNode currentNode) throws PlanningException {
+                                  LogicalNode currentNode) {
     try {
       GroupbyNode groupbyNode = (GroupbyNode)currentNode;
       LogicalPlan plan = context.getPlan().getLogicalPlan();
@@ -350,8 +350,7 @@ public class DistinctGroupbyBuilder {
 
       return secondStageBlock;
     } catch (Exception e) {
-      LOG.error(e.getMessage(), e);
-      throw new PlanningException(e);
+      throw new TajoInternalError(e);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteEngine.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteEngine.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteEngine.java
index cc1f3c6..f71c683 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteEngine.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteEngine.java
@@ -22,7 +22,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.tajo.OverridableConf;
 import org.apache.tajo.engine.planner.global.MasterPlan;
-import org.apache.tajo.plan.PlanningException;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.util.ReflectionUtil;
 
 import java.util.LinkedHashMap;
@@ -68,7 +68,7 @@ public class GlobalPlanRewriteEngine {
    * @param plan The plan to be rewritten with all query rewrite rule.
    * @return The rewritten plan.
    */
-  public MasterPlan rewrite(OverridableConf queryContext, MasterPlan plan) throws PlanningException {
+  public MasterPlan rewrite(OverridableConf queryContext, MasterPlan plan) throws TajoException {
     GlobalPlanRewriteRule rule;
     for (Map.Entry<String, GlobalPlanRewriteRule> rewriteRule : rewriteRules.entrySet()) {
       rule = rewriteRule.getValue();

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteRule.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteRule.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteRule.java
index f30160f..3a76c12 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteRule.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/GlobalPlanRewriteRule.java
@@ -20,6 +20,7 @@ package org.apache.tajo.engine.planner.global.rewriter;
 
 import org.apache.tajo.OverridableConf;
 import org.apache.tajo.engine.planner.global.MasterPlan;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.plan.PlanningException;
 
 /**
@@ -48,5 +49,5 @@ public interface GlobalPlanRewriteRule {
    * @param plan Global Plan
    * @return
    */
-  MasterPlan rewrite(MasterPlan plan) throws PlanningException;
+  MasterPlan rewrite(MasterPlan plan) throws TajoException;
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/rules/BroadcastJoinRule.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/rules/BroadcastJoinRule.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/rules/BroadcastJoinRule.java
index 85b5e10..12c3e73 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/rules/BroadcastJoinRule.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/global/rewriter/rules/BroadcastJoinRule.java
@@ -25,6 +25,7 @@ import org.apache.tajo.engine.planner.global.ExecutionBlock;
 import org.apache.tajo.engine.planner.global.GlobalPlanner;
 import org.apache.tajo.engine.planner.global.MasterPlan;
 import org.apache.tajo.engine.planner.global.rewriter.GlobalPlanRewriteRule;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.logical.*;
@@ -89,7 +90,7 @@ public class BroadcastJoinRule implements GlobalPlanRewriteRule {
   }
 
   @Override
-  public MasterPlan rewrite(MasterPlan plan) throws PlanningException{
+  public MasterPlan rewrite(MasterPlan plan) throws TajoException {
     plan.accept(plan.getRoot().getId(), planBuilder);
     plan.accept(plan.getRoot().getId(), planFinalizer);
     return plan;

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/engine/utils/test/ErrorInjectionRewriter.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/utils/test/ErrorInjectionRewriter.java b/tajo-core/src/main/java/org/apache/tajo/engine/utils/test/ErrorInjectionRewriter.java
index 29dc845..6582513 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/utils/test/ErrorInjectionRewriter.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/utils/test/ErrorInjectionRewriter.java
@@ -19,6 +19,7 @@
 package org.apache.tajo.engine.utils.test;
 
 import org.apache.tajo.OverridableConf;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.rewrite.LogicalPlanRewriteRule;
@@ -36,7 +37,7 @@ public class ErrorInjectionRewriter implements LogicalPlanRewriteRule {
   }
 
   @Override
-  public LogicalPlan rewrite(OverridableConf queryContext, LogicalPlan plan) throws PlanningException {
+  public LogicalPlan rewrite(OverridableConf queryContext, LogicalPlan plan) throws TajoException {
     throw new NullPointerException();
   }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java b/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java
index bba5c0b..b7b48ba 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/exec/ExplainPlanPreprocessorForTest.java
@@ -21,6 +21,7 @@ package org.apache.tajo.master.exec;
 import org.apache.hadoop.fs.Path;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.Schema;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.Target;
@@ -42,7 +43,7 @@ public class ExplainPlanPreprocessorForTest {
   private static final PlanShapeFixerContext shapeFixerContext = new PlanShapeFixerContext();
   private static final PlanShapeFixer shapeFixer = new PlanShapeFixer();
 
-  public void prepareTest(LogicalPlan plan) throws PlanningException {
+  public void prepareTest(LogicalPlan plan) throws TajoException {
     // Plan shape fixer
     shapeFixerContext.reset();
     shapeFixer.visit(shapeFixerContext, plan, plan.getRootBlock());
@@ -77,7 +78,7 @@ public class ExplainPlanPreprocessorForTest {
 
     @Override
     public LogicalNode visit(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                             LogicalNode node, Stack<LogicalNode> stack) throws PlanningException {
+                             LogicalNode node, Stack<LogicalNode> stack) throws TajoException {
       super.visit(context, plan, block, node, stack);
       node.setInSchema(sortSchema(node.getInSchema()));
       node.setOutSchema(sortSchema(node.getOutSchema()));
@@ -87,7 +88,7 @@ public class ExplainPlanPreprocessorForTest {
 
     @Override
     public LogicalNode visitFilter(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                   SelectionNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                   SelectionNode node, Stack<LogicalNode> stack) throws TajoException {
       super.visitFilter(context, plan, block, node, stack);
       if (node.hasQual()) {
         node.setQual(sortQual(node.getQual()));
@@ -97,7 +98,7 @@ public class ExplainPlanPreprocessorForTest {
 
     @Override
     public LogicalNode visitScan(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                 ScanNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                 ScanNode node, Stack<LogicalNode> stack) throws TajoException {
       super.visitScan(context, plan, block, node, stack);
       context.childNumbers.push(1);
       if (node.hasTargets()) {
@@ -113,7 +114,7 @@ public class ExplainPlanPreprocessorForTest {
     public LogicalNode visitPartitionedTableScan(PlanShapeFixerContext context, LogicalPlan plan,
                                                  LogicalPlan.QueryBlock block, PartitionedTableScanNode node,
                                                  Stack<LogicalNode> stack)
-        throws PlanningException {
+        throws TajoException {
       super.visitPartitionedTableScan(context, plan, block, node, stack);
       context.childNumbers.push(1);
       Path[] inputPaths = node.getInputPaths();
@@ -130,7 +131,7 @@ public class ExplainPlanPreprocessorForTest {
 
     @Override
     public LogicalNode visitJoin(PlanShapeFixerContext context, LogicalPlan plan, LogicalPlan.QueryBlock block,
-                                 JoinNode node, Stack<LogicalNode> stack) throws PlanningException {
+                                 JoinNode node, Stack<LogicalNode> stack) throws TajoException {
       super.visitJoin(context, plan, block, node, stack);
       int rightChildNum = context.childNumbers.pop();
       int leftChildNum = context.childNumbers.pop();

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/master/exec/NonForwardQueryResultSystemScanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/master/exec/NonForwardQueryResultSystemScanner.java b/tajo-core/src/main/java/org/apache/tajo/master/exec/NonForwardQueryResultSystemScanner.java
index 0ace53a..52c8d79 100644
--- a/tajo-core/src/main/java/org/apache/tajo/master/exec/NonForwardQueryResultSystemScanner.java
+++ b/tajo-core/src/main/java/org/apache/tajo/master/exec/NonForwardQueryResultSystemScanner.java
@@ -40,6 +40,8 @@ import org.apache.tajo.engine.planner.global.GlobalPlanner;
 import org.apache.tajo.engine.planner.global.MasterPlan;
 import org.apache.tajo.engine.planner.physical.PhysicalExec;
 import org.apache.tajo.engine.query.QueryContext;
+import org.apache.tajo.exception.TajoException;
+import org.apache.tajo.exception.TajoInternalError;
 import org.apache.tajo.master.TajoMaster.MasterContext;
 import org.apache.tajo.master.rm.NodeStatus;
 import org.apache.tajo.plan.InvalidQueryException;
@@ -101,8 +103,8 @@ public class NonForwardQueryResultSystemScanner implements NonForwardQueryResult
     GlobalPlanner globalPlanner = new GlobalPlanner(masterContext.getConf(), masterContext.getCatalog());
     try {
       globalPlanner.build(queryContext, masterPlan);
-    } catch (PlanningException e) {
-      throw new RuntimeException(e);
+    } catch (TajoException e) {
+      throw new TajoInternalError(e);
     }
     
     ExecutionBlockCursor cursor = new ExecutionBlockCursor(masterPlan);

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/main/java/org/apache/tajo/worker/ExecutionBlockSharedResource.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/worker/ExecutionBlockSharedResource.java b/tajo-core/src/main/java/org/apache/tajo/worker/ExecutionBlockSharedResource.java
index 494fd7f..1a83104 100644
--- a/tajo-core/src/main/java/org/apache/tajo/worker/ExecutionBlockSharedResource.java
+++ b/tajo-core/src/main/java/org/apache/tajo/worker/ExecutionBlockSharedResource.java
@@ -31,7 +31,7 @@ import org.apache.tajo.engine.query.QueryContext;
 import org.apache.tajo.engine.utils.CacheHolder;
 import org.apache.tajo.engine.utils.TableCache;
 import org.apache.tajo.engine.utils.TableCacheKey;
-import org.apache.tajo.plan.PlanningException;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.plan.logical.LogicalNode;
 import org.apache.tajo.util.Pair;
@@ -76,7 +76,7 @@ public class ExecutionBlockSharedResource {
     plan = CoreGsonHelper.fromJson(planJson, LogicalNode.class);
   }
 
-  private void initCodeGeneration() throws PlanningException {
+  private void initCodeGeneration() throws TajoException {
     if (context.getBool(SessionVars.CODEGEN)) {
       codeGenEnabled = true;
       classLoader = new TajoClassLoader();

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java b/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java
index 295ddbc..4e9fb8a 100644
--- a/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java
+++ b/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java
@@ -35,11 +35,11 @@ import org.apache.tajo.client.TajoClient;
 import org.apache.tajo.conf.TajoConf;
 import org.apache.tajo.engine.parser.SQLAnalyzer;
 import org.apache.tajo.engine.query.QueryContext;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.master.GlobalEngine;
 import org.apache.tajo.plan.LogicalOptimizer;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.LogicalPlanner;
-import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.verifier.LogicalPlanVerifier;
 import org.apache.tajo.plan.verifier.PreLogicalPlanVerifier;
 import org.apache.tajo.plan.verifier.VerificationState;
@@ -280,13 +280,15 @@ public class QueryTestCaseBase {
     return currentDatabase;
   }
 
-  private static VerificationState verify(String query) throws PlanningException {
+  private static VerificationState verify(String query) throws TajoException {
 
     VerificationState state = new VerificationState();
     QueryContext context = LocalTajoTestingUtility.createDummyContext(conf);
 
     Expr expr = sqlParser.parse(query);
+
     verifier.verify(context, state, expr);
+
     if (state.getErrors().size() > 0) {
       return state;
     }
@@ -297,38 +299,50 @@ public class QueryTestCaseBase {
     return state;
   }
 
-  public void assertValidSQL(String query) throws PlanningException, IOException {
-    VerificationState state = verify(query);
-    if (state.getErrors().size() > 0) {
-      fail(state.getErrors().get(0).getMessage());
+  public void assertValidSQL(String query) throws IOException {
+    VerificationState state = null;
+    try {
+      state = verify(query);
+      if (state.getErrors().size() > 0) {
+        fail(state.getErrors().get(0).getMessage());
+      }
+    } catch (TajoException e) {
+      throw new RuntimeException(e);
     }
   }
 
-  public void assertValidSQLFromFile(String fileName) throws PlanningException, IOException {
+  public void assertValidSQLFromFile(String fileName) throws IOException {
     Path queryFilePath = getQueryFilePath(fileName);
     String query = FileUtil.readTextFile(new File(queryFilePath.toUri()));
     assertValidSQL(query);
   }
 
-  public void assertInvalidSQL(String query) throws PlanningException, IOException {
-    VerificationState state = verify(query);
-    if (state.getErrors().size() == 0) {
-      fail(PreLogicalPlanVerifier.class.getSimpleName() + " cannot catch any verification error: " + query);
+  public void assertInvalidSQL(String query) throws IOException {
+    VerificationState state = null;
+    try {
+      state = verify(query);
+
+      if (state.getErrors().size() == 0) {
+        fail(PreLogicalPlanVerifier.class.getSimpleName() + " cannot catch any verification error: " + query);
+      }
+
+    } catch (TajoException e) {
+      throw new RuntimeException(e);
     }
   }
 
-  public void assertInvalidSQLFromFile(String fileName) throws PlanningException, IOException {
+  public void assertInvalidSQLFromFile(String fileName) throws IOException {
     Path queryFilePath = getQueryFilePath(fileName);
     String query = FileUtil.readTextFile(new File(queryFilePath.toUri()));
     assertInvalidSQL(query);
   }
 
-  public void assertPlanError(String fileName) throws PlanningException, IOException {
+  public void assertPlanError(String fileName) throws IOException {
     Path queryFilePath = getQueryFilePath(fileName);
     String query = FileUtil.readTextFile(new File(queryFilePath.toUri()));
     try {
       verify(query);
-    } catch (PlanningException e) {
+    } catch (TajoException e) {
       return;
     }
     fail("Cannot catch any planning error from: " + query);

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java b/tajo-core/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
index b9bdbf5..350a4ad 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
@@ -35,6 +35,8 @@ import org.apache.tajo.engine.codegen.TajoClassLoader;
 import org.apache.tajo.engine.function.FunctionLoader;
 import org.apache.tajo.engine.json.CoreGsonHelper;
 import org.apache.tajo.engine.parser.SQLAnalyzer;
+import org.apache.tajo.exception.TajoException;
+import org.apache.tajo.exception.TajoInternalError;
 import org.apache.tajo.function.FunctionSignature;
 import org.apache.tajo.master.exec.QueryExecutor;
 import org.apache.tajo.plan.*;
@@ -133,7 +135,7 @@ public class ExprTestBase {
    * @throws PlanningException
    */
   private static Target[] getRawTargets(QueryContext context, String query, boolean condition)
-      throws PlanningException, InvalidStatementException {
+      throws TajoException, InvalidStatementException {
 
     List<ParsedResult> parsedResults = SimpleParser.parseScript(query);
     if (parsedResults.size() > 1) {
@@ -144,7 +146,7 @@ public class ExprTestBase {
     preLogicalPlanVerifier.verify(context, state, expr);
     if (state.getErrors().size() > 0) {
       if (!condition && state.getErrors().size() > 0) {
-        throw new PlanningException(state.getErrors().get(0));
+        throw new RuntimeException(state.getErrors().get(0));
       }
       assertFalse(state.getErrors().get(0).getMessage(), true);
     }
@@ -158,7 +160,7 @@ public class ExprTestBase {
 
     Target [] targets = plan.getRootBlock().getRawTargets();
     if (targets == null) {
-      throw new PlanningException("Wrong query statement or query plan: " + parsedResults.get(0).getHistoryStatement());
+      throw new RuntimeException("Wrong query statement or query plan: " + parsedResults.get(0).getHistoryStatement());
     }
 
     // Trying regression test for cloning, (de)serialization for json and protocol buffer
@@ -313,7 +315,7 @@ public class ExprTestBase {
       }
     } catch (InvalidStatementException e) {
       assertFalse(e.getMessage(), true);
-    } catch (PlanningException e) {
+    } catch (TajoException e) {
       // In failure test case, an exception must occur while executing query.
       // So, we should check an error message, and return it.
       if (!condition) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java b/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
index 5a8238c..37d665e 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/eval/TestEvalTreeUtil.java
@@ -34,9 +34,9 @@ import org.apache.tajo.engine.function.FunctionLoader;
 import org.apache.tajo.engine.parser.SQLAnalyzer;
 import org.apache.tajo.engine.query.QueryContext;
 import org.apache.tajo.exception.InternalException;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.LogicalPlanner;
-import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.Target;
 import org.apache.tajo.plan.expr.*;
 import org.apache.tajo.plan.exprrewrite.EvalTreeOptimizer;
@@ -141,22 +141,16 @@ public class TestEvalTreeUtil {
     LogicalPlan plan = null;
     try {
       plan = planner.createPlan(defaultContext, expr);
-    } catch (PlanningException e) {
-      e.printStackTrace();
+    } catch (TajoException e) {
+      throw new RuntimeException(e);
     }
 
     return plan.getRootBlock().getRawTargets();
   }
 
-  public static EvalNode getRootSelection(String query) throws PlanningException {
-
+  public static EvalNode getRootSelection(String query) throws TajoException {
     Expr block = analyzer.parse(query);
-    LogicalPlan plan = null;
-    try {
-      plan = planner.createPlan(defaultContext, block);
-    } catch (PlanningException e) {
-      e.printStackTrace();
-    }
+    LogicalPlan plan = planner.createPlan(defaultContext, block);
 
     LogicalPlanner.PlanContext context = new LogicalPlanner.PlanContext(defaultContext, plan, plan.getRootBlock(),
         new EvalTreeOptimizer(), true);
@@ -230,7 +224,7 @@ public class TestEvalTreeUtil {
   }
 
   @Test
-  public final void testGetContainExprs() throws CloneNotSupportedException, PlanningException {
+  public final void testGetContainExprs() throws CloneNotSupportedException, TajoException {
     Expr expr = analyzer.parse(QUERIES[1]);
     LogicalPlan plan = planner.createPlan(defaultContext, expr, true);
     Target [] targets = plan.getRootBlock().getRawTargets();
@@ -251,7 +245,7 @@ public class TestEvalTreeUtil {
   }
   
   @Test
-  public final void testGetCNF() throws PlanningException {
+  public final void testGetCNF() throws TajoException {
     // "select score from people where score < 10 and 4 < score "
     EvalNode node = getRootSelection(QUERIES[5]);
     EvalNode [] cnf = AlgebraicUtil.toConjunctiveNormalFormArray(node);
@@ -274,7 +268,7 @@ public class TestEvalTreeUtil {
   }
   
   @Test
-  public final void testTransformCNF2Singleton() throws PlanningException {
+  public final void testTransformCNF2Singleton() throws TajoException {
     // "select score from people where score < 10 and 4 < score "
     EvalNode node = getRootSelection(QUERIES[6]);
     EvalNode [] cnf1 = AlgebraicUtil.toConjunctiveNormalFormArray(node);
@@ -289,7 +283,7 @@ public class TestEvalTreeUtil {
   }
 
   @Test
-  public final void testGetDNF() throws PlanningException {
+  public final void testGetDNF() throws TajoException {
     // "select score from people where score > 1 and score < 3 or score > 7 and score < 10", // 7
     EvalNode node = getRootSelection(QUERIES[7]);
     EvalNode [] cnf = AlgebraicUtil.toDisjunctiveNormalFormArray(node);
@@ -300,7 +294,7 @@ public class TestEvalTreeUtil {
   }
   
   @Test
-  public final void testSimplify() throws PlanningException {
+  public final void testSimplify() throws TajoException {
     Target [] targets = getRawTargets(QUERIES[0]);
     EvalNode node = AlgebraicUtil.eliminateConstantExprs(targets[0].getEvalTree());
     assertEquals(EvalType.CONST, node.getType());
@@ -319,7 +313,7 @@ public class TestEvalTreeUtil {
   }
   
   @Test
-  public final void testConatainSingleVar() throws PlanningException {
+  public final void testConatainSingleVar() throws TajoException {
     EvalNode node = getRootSelection(QUERIES[2]);
     assertEquals(true, AlgebraicUtil.containSingleVar(node));
     node = getRootSelection(QUERIES[3]);
@@ -327,7 +321,7 @@ public class TestEvalTreeUtil {
   }
   
   @Test
-  public final void testTranspose() throws PlanningException {
+  public final void testTranspose() throws TajoException {
     Column col1 = new Column("default.people.score", TajoDataTypes.Type.INT4);
     EvalNode node = getRootSelection(QUERIES[3]);
     // we expect that score < 3
@@ -347,7 +341,7 @@ public class TestEvalTreeUtil {
   }
 
   @Test
-  public final void testFindDistinctAggFunctions() throws PlanningException {
+  public final void testFindDistinctAggFunctions() throws TajoException {
     String query = "select sum(score) + max(age) from people";
     Expr expr = analyzer.parse(query);
     LogicalPlan plan = planner.createPlan(defaultContext, expr);
@@ -367,13 +361,13 @@ public class TestEvalTreeUtil {
   }
 
   @Test
-  public final void testIsJoinQual() throws PlanningException {
+  public final void testIsJoinQual() throws TajoException {
     EvalNode evalNode = getRootSelection("select score from people where people.score > people.age");
     assertFalse(EvalTreeUtil.isJoinQual(evalNode, true));
   }
 
   @Test
-  public final void testIsJoinQual2() throws PlanningException {
+  public final void testIsJoinQual2() throws TajoException {
     EvalNode evalNode = getRootSelection(
         "select score from people where substr(people.score::text,1,1) > substr(people.age::text,1,1)");
     assertFalse(EvalTreeUtil.isJoinQual(evalNode, true));

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java b/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java
index afa3472..ae3fd11 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalOptimizer.java
@@ -29,10 +29,10 @@ import org.apache.tajo.engine.function.FunctionLoader;
 import org.apache.tajo.engine.function.builtin.SumInt;
 import org.apache.tajo.engine.parser.SQLAnalyzer;
 import org.apache.tajo.engine.query.QueryContext;
+import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.plan.LogicalOptimizer;
 import org.apache.tajo.plan.LogicalPlan;
 import org.apache.tajo.plan.LogicalPlanner;
-import org.apache.tajo.plan.PlanningException;
 import org.apache.tajo.plan.logical.*;
 import org.apache.tajo.storage.TablespaceManager;
 import org.apache.tajo.util.CommonTestingUtil;
@@ -64,7 +64,7 @@ public class TestLogicalOptimizer {
     for (FunctionDesc funcDesc : FunctionLoader.findLegacyFunctions()) {
       catalog.createFunction(funcDesc);
     }
-    
+
     Schema schema = new Schema();
     schema.addColumn("name", Type.TEXT);
     schema.addColumn("empid", Type.INT4);
@@ -113,7 +113,7 @@ public class TestLogicalOptimizer {
   public static void tearDown() throws Exception {
     util.shutdownCatalogCluster();
   }
-  
+
   static String[] QUERIES = {
     "select name, manager from employee as e, dept as dp where e.deptName = dp.deptName", // 0
     "select name, empId, deptName from employee where empId > 500", // 1
@@ -122,9 +122,9 @@ public class TestLogicalOptimizer {
     "select name, score from employee natural join score", // 4
     "select name, score from employee join score on employee.deptName = score.deptName", // 5
   };
-  
+
   @Test
-  public final void testProjectionPushWithNaturalJoin() throws PlanningException, CloneNotSupportedException {
+  public final void testProjectionPushWithNaturalJoin() throws TajoException, CloneNotSupportedException {
     // two relations
     Expr expr = sqlAnalyzer.parse(QUERIES[4]);
     LogicalPlan newPlan = planner.createPlan(defaultContext, expr);
@@ -138,7 +138,7 @@ public class TestLogicalOptimizer {
     JoinNode joinNode = projNode.getChild();
     assertEquals(NodeType.SCAN, joinNode.getLeftChild().getType());
     assertEquals(NodeType.SCAN, joinNode.getRightChild().getType());
-    
+
     LogicalNode optimized = optimizer.optimize(newPlan);
 
     assertEquals(NodeType.ROOT, optimized.getType());
@@ -149,22 +149,22 @@ public class TestLogicalOptimizer {
     assertEquals(NodeType.SCAN, joinNode.getLeftChild().getType());
     assertEquals(NodeType.SCAN, joinNode.getRightChild().getType());
   }
-  
+
   @Test
-  public final void testProjectionPushWithInnerJoin() throws PlanningException {
+  public final void testProjectionPushWithInnerJoin() throws TajoException {
     // two relations
     Expr expr = sqlAnalyzer.parse(QUERIES[5]);
     LogicalPlan newPlan = planner.createPlan(defaultContext, expr);
     optimizer.optimize(newPlan);
   }
-  
+
   @Test
-  public final void testProjectionPush() throws CloneNotSupportedException, PlanningException {
+  public final void testProjectionPush() throws CloneNotSupportedException, TajoException {
     // two relations
     Expr expr = sqlAnalyzer.parse(QUERIES[2]);
     LogicalPlan newPlan = planner.createPlan(defaultContext, expr);
     LogicalNode plan = newPlan.getRootBlock().getRoot();
-    
+
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
     TestLogicalPlanner.testCloneLogicalNode(root);
@@ -180,13 +180,13 @@ public class TestLogicalOptimizer {
     TestLogicalPlanner.testCloneLogicalNode(root);
     assertEquals(NodeType.SCAN, root.getChild().getType());
   }
-  
+
   @Test
-  public final void testOptimizeWithGroupBy() throws CloneNotSupportedException, PlanningException {
+  public final void testOptimizeWithGroupBy() throws CloneNotSupportedException, TajoException {
     Expr expr = sqlAnalyzer.parse(QUERIES[3]);
     LogicalPlan newPlan = planner.createPlan(defaultContext, expr);
     LogicalNode plan = newPlan.getRootBlock().getRoot();
-        
+
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
     TestLogicalPlanner.testCloneLogicalNode(root);
@@ -197,7 +197,7 @@ public class TestLogicalOptimizer {
     assertEquals(NodeType.SELECTION, groupbyNode.getChild().getType());
     SelectionNode selNode = groupbyNode.getChild();
     assertEquals(NodeType.SCAN, selNode.getChild().getType());
-    
+
     LogicalNode optimized = optimizer.optimize(newPlan);
     assertEquals(NodeType.ROOT, optimized.getType());
     root = (LogicalRootNode) optimized;
@@ -208,12 +208,12 @@ public class TestLogicalOptimizer {
   }
 
   @Test
-  public final void testPushable() throws CloneNotSupportedException, PlanningException {
+  public final void testPushable() throws CloneNotSupportedException, TajoException {
     // two relations
     Expr expr = sqlAnalyzer.parse(QUERIES[0]);
     LogicalPlan newPlan = planner.createPlan(defaultContext, expr);
     LogicalNode plan = newPlan.getRootBlock().getRoot();
-    
+
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
     TestLogicalPlanner.testCloneLogicalNode(root);
@@ -223,28 +223,28 @@ public class TestLogicalOptimizer {
 
     assertEquals(NodeType.SELECTION, projNode.getChild().getType());
     SelectionNode selNode = projNode.getChild();
-    
+
     assertEquals(NodeType.JOIN, selNode.getChild().getType());
     JoinNode joinNode = selNode.getChild();
     assertFalse(joinNode.hasJoinQual());
-    
+
     // Test for Pushable
     assertTrue(LogicalPlanner.checkIfBeEvaluatedAtJoin(newPlan.getRootBlock(), selNode.getQual(), joinNode, false));
-    
+
     // Optimized plan
     LogicalNode optimized = optimizer.optimize(newPlan);
     assertEquals(NodeType.ROOT, optimized.getType());
     root = (LogicalRootNode) optimized;
-    
+
     assertEquals(NodeType.JOIN, root.getChild().getType());
     joinNode = root.getChild();
     assertTrue(joinNode.hasJoinQual());
-    
+
     // Scan Pushable Test
     expr = sqlAnalyzer.parse(QUERIES[1]);
     newPlan = planner.createPlan(defaultContext, expr);
     plan = newPlan.getRootBlock().getRoot();
-    
+
     assertEquals(NodeType.ROOT, plan.getType());
     root = (LogicalRootNode) plan;
     TestLogicalPlanner.testCloneLogicalNode(root);
@@ -254,7 +254,7 @@ public class TestLogicalOptimizer {
 
     assertEquals(NodeType.SELECTION, projNode.getChild().getType());
     selNode = projNode.getChild();
-    
+
     assertEquals(NodeType.SCAN, selNode.getChild().getType());
     ScanNode scanNode = selNode.getChild();
     // Test for Join Node
@@ -262,7 +262,7 @@ public class TestLogicalOptimizer {
   }
 
   @Test
-  public final void testInsertInto() throws CloneNotSupportedException, PlanningException {
+  public final void testInsertInto() throws CloneNotSupportedException, TajoException {
     Expr expr = sqlAnalyzer.parse(TestLogicalPlanner.insertStatements[0]);
     LogicalPlan newPlan = planner.createPlan(defaultContext, expr);
     optimizer.optimize(newPlan);

http://git-wip-us.apache.org/repos/asf/tajo/blob/4841c656/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java b/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
index d1b0c37..c01adb5 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/planner/TestLogicalPlanner.java
@@ -40,11 +40,15 @@ import org.apache.tajo.engine.function.builtin.SumInt;
 import org.apache.tajo.engine.json.CoreGsonHelper;
 import org.apache.tajo.engine.parser.SQLAnalyzer;
 import org.apache.tajo.engine.query.QueryContext;
-import org.apache.tajo.session.Session;
-import org.apache.tajo.plan.*;
+import org.apache.tajo.exception.TajoException;
+import org.apache.tajo.plan.LogicalOptimizer;
+import org.apache.tajo.plan.LogicalPlan;
+import org.apache.tajo.plan.LogicalPlanner;
+import org.apache.tajo.plan.Target;
 import org.apache.tajo.plan.expr.*;
 import org.apache.tajo.plan.logical.*;
 import org.apache.tajo.plan.util.PlannerUtil;
+import org.apache.tajo.session.Session;
 import org.apache.tajo.storage.TablespaceManager;
 import org.apache.tajo.util.CommonTestingUtil;
 import org.apache.tajo.util.FileUtil;
@@ -61,7 +65,6 @@ import java.util.*;
 import static org.apache.tajo.TajoConstants.DEFAULT_DATABASE_NAME;
 import static org.apache.tajo.TajoConstants.DEFAULT_TABLESPACE_NAME;
 import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
 
 public class TestLogicalPlanner {
   private static TajoTestingCluster util;
@@ -172,7 +175,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testSingleRelation() throws CloneNotSupportedException, PlanningException {
+  public final void testSingleRelation() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(QUERIES[0]);
@@ -206,7 +209,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testImplicityJoinPlan() throws CloneNotSupportedException, PlanningException {
+  public final void testImplicityJoinPlan() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     // two relations
@@ -295,7 +298,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testNaturalJoinPlan() throws PlanningException {
+  public final void testNaturalJoinPlan() throws TajoException {
     QueryContext qc = createQueryContext();
     // two relations
     Expr context = sqlAnalyzer.parse(JOINS[0]);
@@ -327,7 +330,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testInnerJoinPlan() throws PlanningException {
+  public final void testInnerJoinPlan() throws TajoException {
     QueryContext qc = createQueryContext();
     // two relations
     Expr expr = sqlAnalyzer.parse(JOINS[1]);
@@ -360,7 +363,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testOuterJoinPlan() throws PlanningException {
+  public final void testOuterJoinPlan() throws TajoException {
     QueryContext qc = createQueryContext();
 
     // two relations
@@ -395,7 +398,7 @@ public class TestLogicalPlanner {
 
 
   @Test
-  public final void testGroupby() throws CloneNotSupportedException, PlanningException {
+  public final void testGroupby() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     // without 'having clause'
@@ -437,7 +440,7 @@ public class TestLogicalPlanner {
 
 
   @Test
-  public final void testMultipleJoin() throws IOException, PlanningException {
+  public final void testMultipleJoin() throws IOException, TajoException {
     Expr expr = sqlAnalyzer.parse(
         FileUtil.readTextFile(new File("src/test/resources/queries/TestJoinQuery/testTPCHQ2Join.sql")));
     QueryContext qc = createQueryContext();
@@ -449,7 +452,7 @@ public class TestLogicalPlanner {
 
   private final void findJoinQual(EvalNode evalNode, Map<BinaryEval, Boolean> qualMap,
                                   EvalType leftType, EvalType rightType)
-      throws IOException, PlanningException {
+      throws IOException, TajoException {
     Preconditions.checkArgument(evalNode instanceof BinaryEval);
     BinaryEval qual = (BinaryEval)evalNode;
 
@@ -495,7 +498,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testJoinWithMultipleJoinQual1() throws IOException, PlanningException {
+  public final void testJoinWithMultipleJoinQual1() throws IOException, TajoException {
     Expr expr = sqlAnalyzer.parse(
         FileUtil.readTextFile(new File
             ("src/test/resources/queries/TestJoinQuery/testJoinWithMultipleJoinQual1.sql")));
@@ -537,7 +540,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testJoinWithMultipleJoinQual2() throws IOException, PlanningException {
+  public final void testJoinWithMultipleJoinQual2() throws IOException, TajoException {
     Expr expr = sqlAnalyzer.parse(
         FileUtil.readTextFile(new File
             ("src/test/resources/queries/TestJoinQuery/testJoinWithMultipleJoinQual2.sql")));
@@ -578,7 +581,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testJoinWithMultipleJoinQual3() throws IOException, PlanningException {
+  public final void testJoinWithMultipleJoinQual3() throws IOException, TajoException {
     Expr expr = sqlAnalyzer.parse(
         FileUtil.readTextFile(new File
             ("src/test/resources/queries/TestJoinQuery/testJoinWithMultipleJoinQual3.sql")));
@@ -625,7 +628,7 @@ public class TestLogicalPlanner {
 
 
   @Test
-  public final void testJoinWithMultipleJoinQual4() throws IOException, PlanningException {
+  public final void testJoinWithMultipleJoinQual4() throws IOException, TajoException {
     Expr expr = sqlAnalyzer.parse(
         FileUtil.readTextFile(new File
             ("src/test/resources/queries/TestJoinQuery/testJoinWithMultipleJoinQual4.sql")));
@@ -719,7 +722,7 @@ public class TestLogicalPlanner {
 
 
   @Test
-  public final void testStoreTable() throws CloneNotSupportedException, PlanningException {
+  public final void testStoreTable() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     Expr context = sqlAnalyzer.parse(QUERIES[8]);
@@ -737,7 +740,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testOrderBy() throws CloneNotSupportedException, PlanningException {
+  public final void testOrderBy() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(QUERIES[4]);
@@ -767,7 +770,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testLimit() throws CloneNotSupportedException, PlanningException {
+  public final void testLimit() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(QUERIES[12]);
@@ -789,7 +792,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testSPJPush() throws CloneNotSupportedException, PlanningException {
+  public final void testSPJPush() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(QUERIES[5]);
@@ -811,7 +814,7 @@ public class TestLogicalPlanner {
 
 
   @Test
-  public final void testSPJ() throws CloneNotSupportedException, PlanningException {
+  public final void testSPJ() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(QUERIES[6]);
@@ -821,7 +824,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testJson() throws PlanningException {
+  public final void testJson() throws TajoException {
     QueryContext qc = createQueryContext();
 
 	  Expr expr = sqlAnalyzer.parse(QUERIES[9]);
@@ -843,7 +846,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testVisitor() throws PlanningException {
+  public final void testVisitor() throws TajoException {
     QueryContext qc = createQueryContext();
 
     // two relations
@@ -870,7 +873,7 @@ public class TestLogicalPlanner {
 
 
   @Test
-  public final void testExprNode() throws PlanningException {
+  public final void testExprNode() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(QUERIES[10]);
@@ -892,7 +895,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testAsterisk() throws CloneNotSupportedException, PlanningException {
+  public final void testAsterisk() throws CloneNotSupportedException, TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(QUERIES[13]);
@@ -922,7 +925,7 @@ public class TestLogicalPlanner {
 
 
   @Test
-  public final void testAlias1() throws PlanningException {
+  public final void testAlias1() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(ALIAS[0]);
@@ -950,7 +953,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testAlias2() throws PlanningException {
+  public final void testAlias2() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(ALIAS[1]);
@@ -971,7 +974,7 @@ public class TestLogicalPlanner {
   };
 
   @Test
-  public final void testCreateTableDef() throws PlanningException {
+  public final void testCreateTableDef() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(CREATE_TABLE[0]);
@@ -1057,7 +1060,7 @@ public class TestLogicalPlanner {
   };
 
   @Test
-  public final void testSetPlan() throws PlanningException {
+  public final void testSetPlan() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(setStatements[0]);
@@ -1078,7 +1081,7 @@ public class TestLogicalPlanner {
   };
 
   @Test
-  public void testSetQualifier() throws PlanningException {
+  public void testSetQualifier() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr context = sqlAnalyzer.parse(setQualifiers[0]);
@@ -1131,7 +1134,7 @@ public class TestLogicalPlanner {
   };
 
   @Test
-  public final void testInsertInto0() throws PlanningException {
+  public final void testInsertInto0() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(insertStatements[0]);
@@ -1144,7 +1147,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testInsertInto1() throws PlanningException {
+  public final void testInsertInto1() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(insertStatements[1]);
@@ -1156,7 +1159,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testInsertInto2() throws PlanningException {
+  public final void testInsertInto2() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(insertStatements[2]);
@@ -1171,7 +1174,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testInsertInto3() throws PlanningException {
+  public final void testInsertInto3() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(insertStatements[3]);
@@ -1183,7 +1186,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testInsertInto4() throws PlanningException {
+  public final void testInsertInto4() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(insertStatements[4]);
@@ -1199,7 +1202,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testInsertInto5() throws PlanningException {
+  public final void testInsertInto5() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(insertStatements[5]);
@@ -1211,7 +1214,7 @@ public class TestLogicalPlanner {
   }
 
   @Test
-  public final void testInsertInto6() throws PlanningException {
+  public final void testInsertInto6() throws TajoException {
     QueryContext qc = createQueryContext();
 
     Expr expr = sqlAnalyzer.parse(insertStatements[6]);
@@ -1241,7 +1244,7 @@ public class TestLogicalPlanner {
   };
 
   @Test
-  public final void testAddPartitionAndDropPartition() throws PlanningException {
+  public final void testAddPartitionAndDropPartition() throws TajoException {
     String tableName = CatalogUtil.normalizeIdentifier("partitioned_table");
     String qualifiedTableName = CatalogUtil.buildFQName(DEFAULT_DATABASE_NAME, tableName);
 
@@ -1268,7 +1271,7 @@ public class TestLogicalPlanner {
       desc = new TableDesc(qualifiedTableName, schema, "CSV", new KeyValueSet(),
         CommonTestingUtil.getTestDir().toUri());
     } catch (Exception e) {
-      throw new PlanningException(e.getMessage());
+      throw new RuntimeException(e);
     }
 
     desc.setPartitionMethod(partitionMethodDesc);


Mime
View raw message