tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [2/2] tajo git commit: TAJO-2127: Use Type instead of DataType for EvalNode.
Date Fri, 22 Apr 2016 12:06:51 GMT
TAJO-2127: Use Type instead of DataType for EvalNode.

Closes #1005


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

Branch: refs/heads/master
Commit: 552376a80283edf8ac974d55291c4568ba17fc96
Parents: dc96f7e
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Fri Apr 22 05:04:17 2016 -0700
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Fri Apr 22 05:04:17 2016 -0700

----------------------------------------------------------------------
 CHANGES                                         |   2 +
 .../main/java/org/apache/tajo/DataTypeUtil.java |  87 +++++++--------
 .../java/org/apache/tajo/catalog/Column.java    |  10 ++
 .../org/apache/tajo/catalog/TypeConverter.java  |  56 +++++++---
 .../exception/InvalidValueForCastException.java |  25 +++--
 .../main/java/org/apache/tajo/type/Int1.java    |  28 +++++
 .../main/java/org/apache/tajo/type/Type.java    |  51 ++++-----
 .../java/org/apache/tajo/schema/TestSchema.java |  16 +--
 .../java/org/apache/tajo/type/TestType.java     |  52 ++++-----
 .../apache/tajo/engine/eval/ExprTestBase.java   |  10 --
 .../apache/tajo/engine/eval/TestEvalTree.java   |  55 ++--------
 .../tajo/engine/planner/TestLogicalPlanner.java |  62 -----------
 .../tajo/engine/codegen/EvalCodeGenContext.java |   2 +-
 .../tajo/engine/codegen/EvalCodeGenerator.java  |  31 +++---
 .../codegen/ScalarFunctionBindingEmitter.java   |   5 +-
 .../engine/codegen/TajoGeneratorAdapter.java    | 109 ++++++++++---------
 .../engine/codegen/VariablesPreBuilder.java     |   4 +-
 .../engine/planner/global/GlobalPlanner.java    |   8 +-
 .../worker/ExecutionBlockSharedResource.java    |   6 +-
 .../org/apache/tajo/plan/ExprAnnotator.java     |  45 ++++----
 .../org/apache/tajo/plan/LogicalPlanner.java    |   2 +-
 .../org/apache/tajo/plan/NamedExprsManager.java |   6 +-
 .../org/apache/tajo/plan/TypeDeterminant.java   |  16 +--
 .../plan/expr/AggregationFunctionCallEval.java  |   9 +-
 .../tajo/plan/expr/BetweenPredicateEval.java    |   9 +-
 .../org/apache/tajo/plan/expr/BinaryEval.java   |  18 +--
 .../org/apache/tajo/plan/expr/CaseWhenEval.java |  15 +--
 .../org/apache/tajo/plan/expr/CastEval.java     |   7 +-
 .../org/apache/tajo/plan/expr/ConstEval.java    |   8 +-
 .../org/apache/tajo/plan/expr/EvalNode.java     |   3 +-
 .../org/apache/tajo/plan/expr/EvalTreeUtil.java |   2 +-
 .../org/apache/tajo/plan/expr/FieldEval.java    |  11 +-
 .../org/apache/tajo/plan/expr/FunctionEval.java |   8 +-
 .../java/org/apache/tajo/plan/expr/InEval.java  |   7 +-
 .../org/apache/tajo/plan/expr/IsNullEval.java   |  13 +--
 .../java/org/apache/tajo/plan/expr/NotEval.java |  10 +-
 .../tajo/plan/expr/PartialBinaryExpr.java       |   4 +-
 .../plan/expr/PatternMatchPredicateEval.java    |  10 +-
 .../apache/tajo/plan/expr/RowConstantEval.java  |   9 +-
 .../org/apache/tajo/plan/expr/SignedEval.java   |   4 +-
 .../org/apache/tajo/plan/expr/SubqueryEval.java |   7 +-
 .../org/apache/tajo/plan/expr/UnaryEval.java    |   4 +-
 .../tajo/plan/expr/WindowFunctionEval.java      |   6 +-
 .../tajo/plan/serder/EvalNodeSerializer.java    |   5 +-
 .../tajo/plan/util/EvalNodeToExprConverter.java |   2 +-
 .../org/apache/tajo/plan/util/PlannerUtil.java  |   9 +-
 .../tajo/plan/verifier/ExprsVerifier.java       |  66 ++++++-----
 .../storage/jdbc/SQLExpressionGenerator.java    |   7 +-
 48 files changed, 440 insertions(+), 501 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 829f9a3..7ac7d83 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,8 @@ Release 0.12.0 - unreleased
 
   IMPROVEMENT
 
+    TAJO-2127: Use Type instead of DataType for EvalNode. (hyunsik)
+
     TAJO-2125: Detect JAVA_HOME on OSX, if JAVA_HOME is not set. (jinho)
 
     TAJO-2108: Refactor Schema to be immutable. (hyunsik)

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/DataTypeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/DataTypeUtil.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/DataTypeUtil.java
index c12aa29..9cbdbe0 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/DataTypeUtil.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/DataTypeUtil.java
@@ -19,20 +19,19 @@
 package org.apache.tajo;
 
 import com.google.common.collect.Maps;
-import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.util.TUtil;
 
 import java.util.Map;
 
-import static org.apache.tajo.common.TajoDataTypes.Type;
 import static org.apache.tajo.common.TajoDataTypes.Type.*;
+import static org.apache.tajo.type.Type.*;
 
 public class DataTypeUtil {
 
-  public static final Map<Type, Map<Type, Boolean>> FUNCTION_ACCEPTABLE_PARAM_MAP = Maps.newHashMap();
+  public static final Map<TajoDataTypes.Type, Map<TajoDataTypes.Type, Boolean>> FUNCTION_ACCEPTABLE_PARAM_MAP = Maps.newHashMap();
 
-  private static void putAcceptableType(Type given, Type define) {
+  private static void putAcceptableType(TajoDataTypes.Type given, TajoDataTypes.Type define) {
     TUtil.putToNestedMap(FUNCTION_ACCEPTABLE_PARAM_MAP, given, define, true);
   }
 
@@ -75,8 +74,8 @@ public class DataTypeUtil {
     putAcceptableType(INET4, INET4);
   }
 
-  public static boolean isUpperCastable(Type define, Type given) {
-    if (given == define) {
+  public static boolean isUpperCastable(TajoDataTypes.Type define, TajoDataTypes.Type given) {
+    if (given.equals(define)) {
       return true;
     }
 
@@ -86,92 +85,94 @@ public class DataTypeUtil {
   /**
    * This is verified by ExprsVerifier.checkArithmeticOperand().
    */
-  public static TajoDataTypes.DataType determineType(TajoDataTypes.DataType left, TajoDataTypes.DataType right) {
-    switch (left.getType()) {
+  public static org.apache.tajo.type.Type determineType(org.apache.tajo.type.Type left,
+                                                        org.apache.tajo.type.Type right) {
+    TajoDataTypes.Type rhsBaseType = right.baseType();
+    switch (left.baseType()) {
 
     case INT1:
     case INT2:
     case INT4: {
-      switch(right.getType()) {
+      switch(rhsBaseType) {
       case INT1:
       case INT2:
-      case INT4: return CatalogUtil.newSimpleDataType(Type.INT4);
-      case INT8: return CatalogUtil.newSimpleDataType(Type.INT8);
-      case FLOAT4: return CatalogUtil.newSimpleDataType(Type.FLOAT4);
-      case FLOAT8: return CatalogUtil.newSimpleDataType(Type.FLOAT8);
-      case DATE: return CatalogUtil.newSimpleDataType(Type.DATE);
-      case INTERVAL: return CatalogUtil.newSimpleDataType(Type.INTERVAL);
+      case INT4: return Int4;
+      case INT8: return Int8;
+      case FLOAT4: return Float4;
+      case FLOAT8: return Float8;
+      case DATE: return Date;
+      case INTERVAL: return Interval;
       }
     }
 
     case INT8: {
-      switch(right.getType()) {
+      switch(rhsBaseType) {
       case INT1:
       case INT2:
       case INT4:
-      case INT8: return CatalogUtil.newSimpleDataType(Type.INT8);
-      case FLOAT4: return CatalogUtil.newSimpleDataType(Type.FLOAT4);
-      case FLOAT8: return CatalogUtil.newSimpleDataType(Type.FLOAT8);
-      case DATE: return CatalogUtil.newSimpleDataType(Type.DATE);
-      case INTERVAL: return CatalogUtil.newSimpleDataType(Type.INTERVAL);
+      case INT8: return Int8;
+      case FLOAT4: return Float4;
+      case FLOAT8: return Float8;
+      case DATE: return Date;
+      case INTERVAL: return Interval;
       }
     }
 
     case FLOAT4: {
-      switch(right.getType()) {
+      switch(rhsBaseType) {
       case INT1:
       case INT2:
-      case INT4: return CatalogUtil.newSimpleDataType(Type.FLOAT4);
-      case INT8: return CatalogUtil.newSimpleDataType(Type.FLOAT4);
-      case FLOAT4: return CatalogUtil.newSimpleDataType(Type.FLOAT4);
-      case FLOAT8: return CatalogUtil.newSimpleDataType(Type.FLOAT8);
-      case INTERVAL: return CatalogUtil.newSimpleDataType(Type.INTERVAL);
+      case INT4: return Float4;
+      case INT8: return Float4;
+      case FLOAT4: return Float4;
+      case FLOAT8: return Float8;
+      case INTERVAL: return Interval;
       }
     }
 
     case FLOAT8: {
-      switch(right.getType()) {
+      switch(rhsBaseType) {
       case INT1:
       case INT2:
       case INT4:
       case INT8:
       case FLOAT4:
-      case FLOAT8: return CatalogUtil.newSimpleDataType(Type.FLOAT8);
-      case INTERVAL: return CatalogUtil.newSimpleDataType(Type.INTERVAL);
+      case FLOAT8: return Float8;
+      case INTERVAL: return Interval;
       }
     }
 
     case DATE: {
-      switch(right.getType()) {
+      switch(rhsBaseType) {
       case INT2:
       case INT4:
-      case INT8: return CatalogUtil.newSimpleDataType(Type.DATE);
+      case INT8: return Date;
       case INTERVAL:
-      case TIME: return CatalogUtil.newSimpleDataType(Type.TIMESTAMP);
-      case DATE: return CatalogUtil.newSimpleDataType(Type.INT4);
+      case TIME: return Timestamp;
+      case DATE: return Int4;
       }
     }
 
     case TIME: {
-      switch(right.getType()) {
-      case INTERVAL: return CatalogUtil.newSimpleDataType(Type.TIME);
-      case TIME: return CatalogUtil.newSimpleDataType(Type.INTERVAL);
-      case DATE: return CatalogUtil.newSimpleDataType(Type.INT4);
+      switch(rhsBaseType) {
+      case INTERVAL: return Time;
+      case TIME: return Interval;
+      case DATE: return Int4;
       }
     }
 
     case TIMESTAMP: {
-      switch (right.getType()) {
-      case INTERVAL: return CatalogUtil.newSimpleDataType(Type.TIMESTAMP);
-      case TIMESTAMP: return CatalogUtil.newSimpleDataType(Type.INTERVAL);
+      switch (rhsBaseType) {
+      case INTERVAL: return Timestamp;
+      case TIMESTAMP: return Interval;
       }
     }
 
     case INTERVAL: {
-      switch (right.getType()) {
+      switch (rhsBaseType) {
       case INTERVAL:
       case FLOAT4:
-      case FLOAT8: return CatalogUtil.newSimpleDataType(Type.INTERVAL);
+      case FLOAT8: return Interval;
       }
     }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java
index 12edaa7..641b674 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/Column.java
@@ -26,6 +26,7 @@ import org.apache.tajo.common.ProtoObject;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.json.GsonObject;
+import org.apache.tajo.type.Type;
 
 /**
  * Describes a column. It is an immutable object.
@@ -66,6 +67,15 @@ public class Column implements ProtoObject<ColumnProto>, GsonObject {
   /**
    *
    * @param name Column name
+   * @param type Type
+   */
+  public Column(String name, Type type) {
+    this(name, TypeConverter.convert(type));
+  }
+
+  /**
+   *
+   * @param name Column name
    * @param type Data Type
    * @param typeLength The length of type
    */

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TypeConverter.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TypeConverter.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TypeConverter.java
index f82cc03..f4164d4 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TypeConverter.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/TypeConverter.java
@@ -20,11 +20,11 @@ package org.apache.tajo.catalog;
 
 import com.google.common.collect.ImmutableList;
 import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.exception.NotImplementedException;
 import org.apache.tajo.exception.TajoRuntimeException;
 import org.apache.tajo.exception.UnsupportedException;
 import org.apache.tajo.schema.Schema;
-import org.apache.tajo.type.Protobuf;
-import org.apache.tajo.type.Type;
+import org.apache.tajo.type.*;
 
 import java.util.Collection;
 
@@ -43,36 +43,41 @@ public class TypeConverter {
   public static Type convert(TajoDataTypes.Type legacyBaseType) {
     switch (legacyBaseType) {
     case BOOLEAN:
-      return Bool();
+      return Bool;
     case INT1:
+      return Int1;
     case INT2:
-      return Int2();
+      return Int2;
     case INT4:
-      return Int4();
+      return Int4;
     case INT8:
-      return Int8();
+      return Int8;
     case FLOAT4:
-      return Float4();
+      return Float4;
     case FLOAT8:
-      return Float8();
+      return Float8;
     case DATE:
-      return Date();
+      return Date;
     case TIME:
-      return Time();
+      return Time;
     case TIMESTAMP:
-      return Timestamp();
+      return Timestamp;
     case INTERVAL:
-      return Interval();
+      return Interval;
+    case CHAR:
+      return Char(1); // default len = 1
     case TEXT:
-      return Text();
+      return Text;
     case BLOB:
-      return Blob();
+      return Blob;
     case INET4:
-      return Inet4();
+      return Inet4;
+    case RECORD:
+      throw new TajoRuntimeException(new NotImplementedException("record projection"));
     case NULL_TYPE:
-      return Null();
+      return Null;
     case ANY:
-      return Any();
+      return Any;
     default:
       throw new TajoRuntimeException(new UnsupportedException(legacyBaseType.name()));
     }
@@ -96,6 +101,21 @@ public class TypeConverter {
   }
 
   public static TajoDataTypes.DataType convert(Type type) {
-    return CatalogUtil.newSimpleDataType(type.baseType());
+    switch (type.baseType()) {
+      case CHAR:
+        Char charType = (Char) type;
+        return CatalogUtil.newDataTypeWithLen(TajoDataTypes.Type.CHAR, charType.length());
+      case VARCHAR:
+        Varchar varcharType = (Varchar) type;
+        return CatalogUtil.newDataTypeWithLen(TajoDataTypes.Type.VARCHAR, varcharType.length());
+      case PROTOBUF:
+        Protobuf protobuf = (Protobuf) type;
+        return CatalogUtil.newDataType(TajoDataTypes.Type.PROTOBUF, protobuf.getMessageName());
+      case NUMERIC:
+        Numeric numericType = (Numeric) type;
+        return CatalogUtil.newDataTypeWithLen(TajoDataTypes.Type.NUMERIC, numericType.precision());
+      default:
+        return CatalogUtil.newSimpleDataType(type.baseType());
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-common/src/main/java/org/apache/tajo/exception/InvalidValueForCastException.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/exception/InvalidValueForCastException.java b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidValueForCastException.java
index 5baf7c6..6af8d1a 100644
--- a/tajo-common/src/main/java/org/apache/tajo/exception/InvalidValueForCastException.java
+++ b/tajo-common/src/main/java/org/apache/tajo/exception/InvalidValueForCastException.java
@@ -6,9 +6,9 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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.
@@ -21,19 +21,24 @@ package org.apache.tajo.exception;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.error.Errors;
 import org.apache.tajo.rpc.protocolrecords.PrimitiveProtos.ReturnState;
+import org.apache.tajo.type.Type;
 
 public class InvalidValueForCastException extends TajoException {
-	private static final long serialVersionUID = -7689027447969916148L;
+  private static final long serialVersionUID = -7689027447969916148L;
 
-	public InvalidValueForCastException(ReturnState state) {
-		super(state);
-	}
+  public InvalidValueForCastException(ReturnState state) {
+    super(state);
+  }
 
-	public InvalidValueForCastException(TajoDataTypes.DataType src, TajoDataTypes.DataType target) {
-		super(Errors.ResultCode.INVALID_VALUE_FOR_CAST, src.getType().name(), target.getType().name());
-	}
+  public InvalidValueForCastException(TajoDataTypes.DataType src, TajoDataTypes.DataType target) {
+    super(Errors.ResultCode.INVALID_VALUE_FOR_CAST, src.getType().name(), target.getType().name());
+  }
 
   public InvalidValueForCastException(TajoDataTypes.Type src, TajoDataTypes.Type target) {
     super(Errors.ResultCode.INVALID_VALUE_FOR_CAST, src.name(), target.name());
   }
+
+  public InvalidValueForCastException(Type src, Type target) {
+    super(Errors.ResultCode.INVALID_VALUE_FOR_CAST, src.baseType().name(), target.baseType().name());
+  }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-common/src/main/java/org/apache/tajo/type/Int1.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/type/Int1.java b/tajo-common/src/main/java/org/apache/tajo/type/Int1.java
new file mode 100644
index 0000000..9288328
--- /dev/null
+++ b/tajo-common/src/main/java/org/apache/tajo/type/Int1.java
@@ -0,0 +1,28 @@
+/**
+ * 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.type;
+
+import org.apache.tajo.common.TajoDataTypes;
+
+public class Int1 extends Type {
+  @Override
+  public TajoDataTypes.Type baseType() {
+    return TajoDataTypes.Type.INT1;
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-common/src/main/java/org/apache/tajo/type/Type.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/type/Type.java b/tajo-common/src/main/java/org/apache/tajo/type/Type.java
index e1a7180..fdea07e 100644
--- a/tajo-common/src/main/java/org/apache/tajo/type/Type.java
+++ b/tajo-common/src/main/java/org/apache/tajo/type/Type.java
@@ -25,6 +25,24 @@ import java.util.Collection;
 
 public abstract class Type {
 
+  // No paramter types
+  public static final Any Any = new Any();
+  public static final Null Null = new Null();
+  public static final Bool Bool = new Bool();
+  public static final Int1 Int1 = new Int1();
+  public static final Int2 Int2 = new Int2();
+  public static final Int4 Int4 = new Int4();
+  public static final Int8 Int8 = new Int8();
+  public static final Float4 Float4 = new Float4();
+  public static final Float8 Float8 = new Float8();
+  public static final Date Date = new Date();
+  public static final Time Time = new Time();
+  public static final Timestamp Timestamp = new Timestamp();
+  public static final Interval Interval = new Interval();
+  public static final Text Text = new Text();
+  public static final Blob Blob = new Blob();
+  public static final Inet4 Inet4 = new Inet4();
+
   public abstract TajoDataTypes.Type baseType();
 
   public boolean hasParam() {
@@ -42,10 +60,7 @@ public abstract class Type {
 
   @Override
   public boolean equals(Object t) {
-    if (t instanceof Type) {
-      return ((Type)t).baseType() == baseType();
-    }
-    return false;
+    return t instanceof Type && ((Type)t).baseType() == baseType();
   }
 
   @Override
@@ -57,33 +72,7 @@ public abstract class Type {
     return this.baseType() == TajoDataTypes.Type.RECORD;
   }
 
-  public static Any Any() {
-    return Any.INSTANCE;
-  }
-
-  public static Bool Bool() {
-    return new Bool();
-  }
-
-  public static Int2 Int2() {
-    return new Int2();
-  }
-
-  public static Int4 Int4() {
-    return new Int4();
-  }
-
-  public static Int8 Int8() {
-    return new Int8();
-  }
-
-  public static Float4 Float4() {
-    return new Float4();
-  }
-
-  public static Float8 Float8() {
-    return new Float8();
-  }
+  public boolean isNull() { return this.baseType() == TajoDataTypes.Type.NULL_TYPE; }
 
   public static int DEFAULT_SCALE = 0;
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-common/src/test/java/org/apache/tajo/schema/TestSchema.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/schema/TestSchema.java b/tajo-common/src/test/java/org/apache/tajo/schema/TestSchema.java
index 03cc223..a843bd9 100644
--- a/tajo-common/src/test/java/org/apache/tajo/schema/TestSchema.java
+++ b/tajo-common/src/test/java/org/apache/tajo/schema/TestSchema.java
@@ -32,8 +32,8 @@ public class TestSchema {
 
   @Test
   public final void testSchema1() {
-    NamedType struct1 = Struct($("f12"), Field($("f1"), Int8()), Field($("f2"), Int4()));
-    NamedType struct2 = Struct($("f34"), Field($("f3"), Int8()), Field($("f4"), Int4()));
+    NamedType struct1 = Struct($("f12"), Field($("f1"), Int8), Field($("f2"), Int4));
+    NamedType struct2 = Struct($("f34"), Field($("f3"), Int8), Field($("f4"), Int4));
     Schema schema = Schema(struct1, struct2);
 
     assertEquals(schema.toString(), "f12 record (f1 int8,f2 int4),f34 record (f3 int8,f4 int4)");
@@ -41,9 +41,9 @@ public class TestSchema {
 
   @Test
   public final void testSchema2() {
-    NamedType f1 = Field($("x"), Array(Int8()));
-    NamedType f2 = Field($("y"), Int8());
-    NamedType f3 = Struct($("z"), Field($("z-1"), Time()), Field($("z-2"), Array(Int8())));
+    NamedType f1 = Field($("x"), Array(Int8));
+    NamedType f2 = Field($("y"), Int8);
+    NamedType f3 = Struct($("z"), Field($("z-1"), Time()), Field($("z-2"), Array(Int8)));
     Schema schema = Schema(f1, f2, f3);
 
     assertEquals(schema.toString(), "x array<int8>,y int8,z record (z-1 time,z-2 array<int8>)");
@@ -51,9 +51,9 @@ public class TestSchema {
 
   @Test
   public final void testSchemaWithIdentifiers() {
-    NamedType f1 = Field($("x", "y"), Array(Int8()));
-    NamedType f2 = Field($(_("y"), _("B", true)), Int8());
-    NamedType f3 = Struct($("z"), Field($("z-1"), Time()), Field($("z-2"), Array(Int8())));
+    NamedType f1 = Field($("x", "y"), Array(Int8));
+    NamedType f2 = Field($(_("y"), _("B", true)), Int8);
+    NamedType f3 = Struct($("z"), Field($("z-1"), Time), Field($("z-2"), Array(Int8)));
     Schema schema = Schema(f1, f2, f3);
 
     assertEquals(schema.toString(), "x.y array<int8>,y.'B' int8,z record (z-1 time,z-2 array<int8>)");

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-common/src/test/java/org/apache/tajo/type/TestType.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/type/TestType.java b/tajo-common/src/test/java/org/apache/tajo/type/TestType.java
index 9023af0..910ba0d 100644
--- a/tajo-common/src/test/java/org/apache/tajo/type/TestType.java
+++ b/tajo-common/src/test/java/org/apache/tajo/type/TestType.java
@@ -27,15 +27,16 @@ import static org.junit.Assert.assertEquals;
 public class TestType {
   @Test
   public final void testPrimitiveTypes() {
-    assertEquals(Bool().baseType(), BOOLEAN);
-    assertEquals(Int2().baseType(), INT2);
-    assertEquals(Int4().baseType(), INT4);
-    assertEquals(Int8().baseType(), INT8);
-    assertEquals(Float4().baseType(), FLOAT4);
-    assertEquals(Float8().baseType(), FLOAT8);
-    assertEquals(Date().baseType(), DATE);
-    assertEquals(Time().baseType(), TIME);
-    assertEquals(Timestamp().baseType(), TIMESTAMP);
+    assertEquals(Bool.baseType(), BOOLEAN);
+    assertEquals(Int1.baseType(), INT1);
+    assertEquals(Int2.baseType(), INT2);
+    assertEquals(Int4.baseType(), INT4);
+    assertEquals(Int8.baseType(), INT8);
+    assertEquals(Float4.baseType(), FLOAT4);
+    assertEquals(Float8.baseType(), FLOAT8);
+    assertEquals(Date.baseType(), DATE);
+    assertEquals(Time.baseType(), TIME);
+    assertEquals(Timestamp.baseType(), TIMESTAMP);
 
     Numeric n = Numeric(4, 2);
     assertEquals(n.baseType(), NUMERIC);
@@ -52,37 +53,38 @@ public class TestType {
     assertEquals(varchar.baseType(), VARCHAR);
     assertEquals(varchar.length(), 2);
 
-    Struct struct = Struct(Int8(), Array(Float8()));
+    Struct struct = Struct(Int8, Array(Float8));
     assertEquals(struct.baseType(), RECORD);
     assertEquals(struct.memberType(0).baseType(), INT8);
     assertEquals(struct.memberType(1).baseType(), ARRAY);
 
-    Map map = Map(Int8(), Array(Timestamp()));
+    Map map = Map(Int8, Array(Timestamp()));
     assertEquals(map.baseType(), MAP);
     assertEquals(map.keyType().baseType(), INT8);
     assertEquals(map.valueType().baseType(), ARRAY);
 
-    Array array = Array(Int8());
+    Array array = Array(Int8);
     assertEquals(array.baseType(), ARRAY);
     assertEquals(array.elementType().baseType(), INT8);
   }
 
   @Test
   public final void testToString() {
-    assertEquals("boolean", Bool().toString());
-    assertEquals("int2", Int2().toString());
-    assertEquals("int4", Int4().toString());
-    assertEquals("int8", Int8().toString());
-    assertEquals("float4", Float4().toString());
-    assertEquals("float8", Float8().toString());
-    assertEquals("date", Date().toString());
-    assertEquals("time", Time().toString());
-    assertEquals("timestamp", Timestamp().toString());
+    assertEquals("boolean", Bool.toString());
+    assertEquals("int1", Int1.toString());
+    assertEquals("int2", Int2.toString());
+    assertEquals("int4", Int4.toString());
+    assertEquals("int8", Int8.toString());
+    assertEquals("float4", Float4.toString());
+    assertEquals("float8", Float8.toString());
+    assertEquals("date", Date.toString());
+    assertEquals("time", Time.toString());
+    assertEquals("timestamp", Timestamp.toString());
 
     Numeric n = Numeric(4, 2);
     assertEquals("numeric(4,2)", n.toString());
 
-    assertEquals("blob", Blob().toString());
+    assertEquals("blob", Blob.toString());
 
     Char c = Char(2);
     assertEquals("char(2)", c.toString());
@@ -90,13 +92,13 @@ public class TestType {
     Varchar varchar = Varchar(2);
     assertEquals("varchar(2)", varchar.toString());
 
-    Struct struct = Struct(Int8(), Array(Float8()));
+    Struct struct = Struct(Int8, Array(Float8));
     assertEquals("struct(int8,array<float8>)", struct.toString());
 
-    Map map = Map(Int8(), Array(Timestamp()));
+    Map map = Map(Int8, Array(Timestamp));
     assertEquals("map<int8,array<timestamp>>", map.toString());
 
-    Array array = Array(Int8());
+    Array array = Array(Int8);
     assertEquals("array<int8>", array.toString());
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/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 61faee6..00fa590 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
@@ -33,7 +33,6 @@ import org.apache.tajo.datum.*;
 import org.apache.tajo.engine.codegen.EvalCodeGenerator;
 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.query.QueryContext;
 import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.exception.TajoInternalError;
@@ -119,12 +118,6 @@ public class ExprTestBase {
     cluster.shutdownCatalogCluster();
   }
 
-  private static void assertJsonSerDer(EvalNode expr) {
-    String json = CoreGsonHelper.toJson(expr, EvalNode.class);
-    EvalNode fromJson = CoreGsonHelper.fromJson(json, EvalNode.class);
-    assertEquals(expr, fromJson);
-  }
-
   public TajoConf getConf() {
     return new TajoConf(conf);
   }
@@ -175,9 +168,6 @@ public class ExprTestBase {
       }
     }
     for (Target t : targets) {
-      assertJsonSerDer(t.getEvalTree());
-    }
-    for (Target t : targets) {
       assertEvalTreeProtoSerDer(context, t.getEvalTree());
     }
     return targets;

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTree.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTree.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTree.java
index e74b108..26e0615 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTree.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/eval/TestEvalTree.java
@@ -23,16 +23,15 @@ import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.catalog.SchemaBuilder;
 import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.common.TajoDataTypes.DataType;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.DatumFactory;
-import org.apache.tajo.engine.json.CoreGsonHelper;
 import org.apache.tajo.plan.expr.*;
 import org.apache.tajo.storage.Tuple;
 import org.apache.tajo.storage.VTuple;
+import org.apache.tajo.type.Type;
 import org.junit.Test;
 
-import static org.apache.tajo.common.TajoDataTypes.Type.*;
+import static org.apache.tajo.common.TajoDataTypes.Type.INT4;
 import static org.junit.Assert.*;
 
 public class TestEvalTree extends ExprTestBase {
@@ -93,8 +92,8 @@ public class TestEvalTree extends ExprTestBase {
     }
 
     @Override
-    public DataType getValueType() {
-      return CatalogUtil.newSimpleDataType(BOOLEAN);
+    public Type getValueType() {
+      return Type.Bool;
     }
 
     @Override
@@ -141,8 +140,8 @@ public class TestEvalTree extends ExprTestBase {
     }
 
     @Override
-    public DataType getValueType() {
-      return CatalogUtil.newSimpleDataType(BOOLEAN);
+    public Type getValueType() {
+      return Type.Bool;
     }
 
     @Override
@@ -291,16 +290,16 @@ public class TestEvalTree extends ExprTestBase {
     e1 = new ConstEval(DatumFactory.createInt4(9));
     e2 = new ConstEval(DatumFactory.createInt4(34));
     BinaryEval expr = new BinaryEval(EvalType.PLUS, e1, e2);
-    assertEquals(CatalogUtil.newSimpleDataType(INT4), expr.getValueType());
+    assertEquals(Type.Int4, expr.getValueType());
 
     expr = new BinaryEval(EvalType.LTH, e1, e2);
     assertTrue(expr.bind(null, null).eval(null).asBool());
-    assertEquals(CatalogUtil.newSimpleDataType(BOOLEAN), expr.getValueType());
+    assertEquals(Type.Bool, expr.getValueType());
 
     e1 = new ConstEval(DatumFactory.createFloat8(9.3));
     e2 = new ConstEval(DatumFactory.createFloat8(34.2));
     expr = new BinaryEval(EvalType.PLUS, e1, e2);
-    assertEquals(CatalogUtil.newSimpleDataType(FLOAT8), expr.getValueType());
+    assertEquals(Type.Float8, expr.getValueType());
   }
   
   @Test
@@ -334,42 +333,6 @@ public class TestEvalTree extends ExprTestBase {
     
     assertTrue(compExpr1.equals(compExpr2));
   }
-  
-  @Test
-  public final void testJson() throws CloneNotSupportedException {
-    ConstEval e1;
-    ConstEval e2;
-
-    // 29 > (34 + 5) + (5 + 34)
-    e1 = new ConstEval(DatumFactory.createInt4(34));
-    e2 = new ConstEval(DatumFactory.createInt4(5));
-    assertCloneEqual(e1); 
-    
-    BinaryEval plus1 = new BinaryEval(EvalType.PLUS, e1, e2);
-    assertCloneEqual(plus1);
-    BinaryEval plus2 = new BinaryEval(EvalType.PLUS, e2, e1);
-    assertCloneEqual(plus2);
-    BinaryEval plus3 = new BinaryEval(EvalType.PLUS, plus2, plus1);
-    assertCloneEqual(plus3);
-    
-    ConstEval e3 = new ConstEval(DatumFactory.createInt4(29));
-    BinaryEval gth = new BinaryEval(EvalType.GTH, e3, plus3);
-    assertCloneEqual(gth);
-    
-    String json = gth.toJson();
-    BinaryEval eval = (BinaryEval) CoreGsonHelper.fromJson(json, EvalNode.class);
-    assertCloneEqual(eval);
-    
-    assertEquals(gth.getType(), eval.getType());
-    assertEquals(e3.getType(), eval.getLeftExpr().getType());
-    assertEquals(plus3.getType(), eval.getRightExpr().getType());
-    assertEquals(plus3.getLeftExpr(), ((BinaryEval)eval.getRightExpr()).getLeftExpr());
-    assertEquals(plus3.getRightExpr(), ((BinaryEval) eval.getRightExpr()).getRightExpr());
-    assertEquals(plus2.getLeftExpr(), ((BinaryEval)((BinaryEval)eval.getRightExpr()).getLeftExpr()).getLeftExpr());
-    assertEquals(plus2.getRightExpr(), ((BinaryEval)((BinaryEval)eval.getRightExpr()).getLeftExpr()).getRightExpr());
-    assertEquals(plus1.getLeftExpr(), ((BinaryEval) ((BinaryEval) eval.getRightExpr()).getRightExpr()).getLeftExpr());
-    assertEquals(plus1.getRightExpr(), ((BinaryEval) ((BinaryEval) eval.getRightExpr()).getRightExpr()).getRightExpr());
-  }
 
   @Test
   public final void testBindCheck() {

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/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 d1c8384..d01b0d5 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
@@ -187,7 +187,6 @@ public class TestLogicalPlanner {
     assertEquals(NodeType.ROOT, plan.getType());
     testCloneLogicalNode(plan);
     LogicalRootNode root = (LogicalRootNode) plan;
-    testJsonSerDerObject(root);
 
     assertEquals(NodeType.PROJECTION, root.getChild().getType());
     ProjectionNode projNode = root.getChild();
@@ -222,7 +221,6 @@ public class TestLogicalPlanner {
 
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
-    testJsonSerDerObject(root);
     testCloneLogicalNode(root);
 
     Schema expectedSchema = SchemaBuilder.builder()
@@ -252,7 +250,6 @@ public class TestLogicalPlanner {
     // three relations
     expr = sqlAnalyzer.parse(QUERIES[2]);
     plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     testCloneLogicalNode(plan);
 
     expectedSchema = SchemaBuilder.builder().addAll(expectedSchema.getRootColumns())
@@ -310,7 +307,6 @@ public class TestLogicalPlanner {
     // two relations
     Expr context = sqlAnalyzer.parse(JOINS[0]);
     LogicalNode plan = planner.createPlan(qc, context).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertSchema(expectedJoinSchema, plan.getOutSchema());
 
     assertEquals(NodeType.ROOT, plan.getType());
@@ -343,7 +339,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(JOINS[1]);
     LogicalPlan plan = planner.createPlan(qc, expr);
     LogicalNode root = plan.getRootBlock().getRoot();
-    testJsonSerDerObject(root);
     assertSchema(expectedJoinSchema, root.getOutSchema());
 
     assertEquals(NodeType.ROOT, root.getType());
@@ -376,7 +371,6 @@ public class TestLogicalPlanner {
     // two relations
     Expr expr = sqlAnalyzer.parse(JOINS[2]);
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertSchema(expectedJoinSchema, plan.getOutSchema());
 
     assertEquals(NodeType.ROOT, plan.getType());
@@ -414,7 +408,6 @@ public class TestLogicalPlanner {
 
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
-    testJsonSerDerObject(root);
     testQuery7(root.getChild());
 
     // with having clause
@@ -452,7 +445,6 @@ public class TestLogicalPlanner {
         FileUtil.readTextFile(new File("src/test/resources/queries/TestJoinQuery/testTPCHQ2Join.sql")));
     QueryContext qc = createQueryContext();
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     Schema expected = tpch.getOutSchema("q2");
     assertSchema(expected, plan.getOutSchema());
   }
@@ -513,7 +505,6 @@ public class TestLogicalPlanner {
 
     LogicalPlan plan = planner.createPlan(qc, expr);
     LogicalNode node = plan.getRootBlock().getRoot();
-    testJsonSerDerObject(node);
 
     Schema expected = tpch.getOutSchema("q2");
     assertSchema(expected, node.getOutSchema());
@@ -555,7 +546,6 @@ public class TestLogicalPlanner {
 
     LogicalPlan plan = planner.createPlan(qc,expr);
     LogicalNode node = plan.getRootBlock().getRoot();
-    testJsonSerDerObject(node);
 
     LogicalOptimizer optimizer = new LogicalOptimizer(util.getConfiguration(), catalog, TablespaceManager.getInstance());
     optimizer.optimize(plan);
@@ -596,7 +586,6 @@ public class TestLogicalPlanner {
 
     LogicalPlan plan = planner.createPlan(qc, expr);
     LogicalNode node = plan.getRootBlock().getRoot();
-    testJsonSerDerObject(node);
 
     LogicalOptimizer optimizer = new LogicalOptimizer(util.getConfiguration(), catalog, TablespaceManager.getInstance());
     optimizer.optimize(plan);
@@ -643,7 +632,6 @@ public class TestLogicalPlanner {
 
     LogicalPlan plan = planner.createPlan(qc, expr);
     LogicalNode node = plan.getRootBlock().getRoot();
-    testJsonSerDerObject(node);
 
     LogicalOptimizer optimizer = new LogicalOptimizer(util.getConfiguration(), catalog, TablespaceManager.getInstance());
     optimizer.optimize(plan);
@@ -736,7 +724,6 @@ public class TestLogicalPlanner {
 
     LogicalNode plan = planner.createPlan(qc, context).getRootBlock().getRoot();
     testCloneLogicalNode(plan);
-    testJsonSerDerObject(plan);
 
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
@@ -753,7 +740,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(QUERIES[4]);
 
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     testCloneLogicalNode(plan);
 
     assertEquals(NodeType.ROOT, plan.getType());
@@ -783,7 +769,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(QUERIES[12]);
 
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     testCloneLogicalNode(plan);
 
     assertEquals(NodeType.ROOT, plan.getType());
@@ -804,7 +789,6 @@ public class TestLogicalPlanner {
 
     Expr expr = sqlAnalyzer.parse(QUERIES[5]);
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     testCloneLogicalNode(plan);
 
     assertEquals(NodeType.ROOT, plan.getType());
@@ -826,33 +810,10 @@ public class TestLogicalPlanner {
 
     Expr expr = sqlAnalyzer.parse(QUERIES[6]);
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     testCloneLogicalNode(plan);
   }
 
   @Test
-  public final void testJson() throws TajoException {
-    QueryContext qc = createQueryContext();
-
-	  Expr expr = sqlAnalyzer.parse(QUERIES[9]);
-	  LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
-
-	  String json = plan.toJson();
-	  LogicalNode fromJson = CoreGsonHelper.fromJson(json, LogicalNode.class);
-	  assertEquals(NodeType.ROOT, fromJson.getType());
-	  LogicalNode project = ((LogicalRootNode)fromJson).getChild();
-	  assertEquals(NodeType.PROJECTION, project.getType());
-	  assertEquals(NodeType.HAVING, ((ProjectionNode) project).getChild().getType());
-    HavingNode havingNode = ((ProjectionNode) project).getChild();
-    assertEquals(NodeType.GROUP_BY, havingNode.getChild().getType());
-    GroupbyNode groupbyNode = havingNode.getChild();
-    assertEquals(NodeType.SCAN, groupbyNode.getChild().getType());
-	  LogicalNode scan = groupbyNode.getChild();
-	  assertEquals(NodeType.SCAN, scan.getType());
-  }
-
-  @Test
   public final void testVisitor() throws TajoException {
     QueryContext qc = createQueryContext();
 
@@ -886,7 +847,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(QUERIES[10]);
     LogicalPlan rootNode = planner.createPlan(qc, expr);
     LogicalNode plan = rootNode.getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
     assertEquals(NodeType.EXPRS, root.getChild().getType());
@@ -907,7 +867,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(QUERIES[11]);
     LogicalPlan rootNode = planner.createPlan(qc, expr);
     LogicalNode plan = rootNode.getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
 
     LogicalRootNode root = (LogicalRootNode) plan;
     assertEquals(NodeType.CREATE_INDEX, root.getChild().getType());
@@ -934,7 +893,6 @@ public class TestLogicalPlanner {
     assertEquals(NodeType.ROOT, plan.getType());
     testCloneLogicalNode(plan);
     LogicalRootNode root = (LogicalRootNode) plan;
-    testJsonSerDerObject(root);
 
     assertEquals(NodeType.PROJECTION, root.getChild().getType());
     ProjectionNode projNode = root.getChild();
@@ -961,7 +919,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(ALIAS[0]);
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
     LogicalRootNode root = (LogicalRootNode) plan;
-    testJsonSerDerObject(root);
 
     Schema finalSchema = root.getOutSchema();
     Iterator<Column> it = finalSchema.getRootColumns().iterator();
@@ -989,7 +946,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(ALIAS[1]);
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
     LogicalRootNode root = (LogicalRootNode) plan;
-    testJsonSerDerObject(root);
 
     Schema finalSchema = root.getOutSchema();
     Iterator<Column> it = finalSchema.getRootColumns().iterator();
@@ -1010,7 +966,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(CREATE_TABLE[0]);
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
     LogicalRootNode root = (LogicalRootNode) plan;
-    testJsonSerDerObject(root);
     assertEquals(NodeType.CREATE_TABLE, root.getChild().getType());
     CreateTableNode createTable = root.getChild();
 
@@ -1095,7 +1050,6 @@ public class TestLogicalPlanner {
 
     Expr expr = sqlAnalyzer.parse(setStatements[0]);
     LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
     assertEquals(NodeType.UNION, root.getChild().getType());
@@ -1116,7 +1070,6 @@ public class TestLogicalPlanner {
 
     Expr context = sqlAnalyzer.parse(setQualifiers[0]);
     LogicalNode plan = planner.createPlan(qc, context).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
     assertEquals(NodeType.PROJECTION, root.getChild().getType());
@@ -1125,7 +1078,6 @@ public class TestLogicalPlanner {
 
     context = sqlAnalyzer.parse(setQualifiers[1]);
     plan = planner.createPlan(qc, context).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertEquals(NodeType.ROOT, plan.getType());
     root = (LogicalRootNode) plan;
     assertEquals(NodeType.PROJECTION, root.getChild().getType());
@@ -1134,19 +1086,12 @@ public class TestLogicalPlanner {
 
     context = sqlAnalyzer.parse(setQualifiers[2]);
     plan = planner.createPlan(qc, context).getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     root = (LogicalRootNode) plan;
     assertEquals(NodeType.PROJECTION, root.getChild().getType());
     projectionNode = root.getChild();
     assertEquals(NodeType.SCAN, projectionNode.getChild().getType());
   }
 
-  public void testJsonSerDerObject(LogicalNode rootNode) {
-    String json = rootNode.toJson();
-    LogicalNode fromJson = CoreGsonHelper.fromJson(json, LogicalNode.class);
-    assertTrue("JSON (de) serialization equivalence check", rootNode.deepEquals(fromJson));
-  }
-
   // Table descriptions
   //
   // employee (name text, empid int4, deptname text)
@@ -1275,7 +1220,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(sql);
     LogicalPlan rootNode = planner.createPlan(qc, expr);
     LogicalNode plan = rootNode.getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
     assertEquals(NodeType.ALTER_TABLE, root.getChild().getType());
@@ -1341,7 +1285,6 @@ public class TestLogicalPlanner {
     Expr expr = sqlAnalyzer.parse(ALTER_PARTITIONS[0]);
     LogicalPlan rootNode = planner.createPlan(qc, expr);
     LogicalNode plan = rootNode.getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertEquals(NodeType.ROOT, plan.getType());
     LogicalRootNode root = (LogicalRootNode) plan;
     assertEquals(NodeType.ALTER_TABLE, root.getChild().getType());
@@ -1365,7 +1308,6 @@ public class TestLogicalPlanner {
     expr = sqlAnalyzer.parse(ALTER_PARTITIONS[1]);
     rootNode = planner.createPlan(qc, expr);
     plan = rootNode.getRootBlock().getRoot();
-    testJsonSerDerObject(plan);
     assertEquals(NodeType.ROOT, plan.getType());
     root = (LogicalRootNode) plan;
     assertEquals(NodeType.ALTER_TABLE, root.getChild().getType());
@@ -1407,12 +1349,10 @@ public class TestLogicalPlanner {
     LogicalNode node = logicalPlan.getRootNode();
     assertEquals(NodeType.ROOT, node.getType());
     LogicalRootNode root = (LogicalRootNode) node;
-    testJsonSerDerObject(root);
     testCloneLogicalNode(root);
 
     assertEquals(NodeType.PROJECTION, root.getChild().getType());
     ProjectionNode projectionNode = root.getChild();
-    testJsonSerDerObject(projectionNode);
     testCloneLogicalNode(projectionNode);
 
     // projection column test
@@ -1462,12 +1402,10 @@ public class TestLogicalPlanner {
     LogicalNode node = logicalPlan.getRootNode();
     assertEquals(NodeType.ROOT, node.getType());
     LogicalRootNode root = (LogicalRootNode) node;
-    testJsonSerDerObject(root);
     testCloneLogicalNode(root);
 
     assertEquals(NodeType.PROJECTION, root.getChild().getType());
     ProjectionNode projectionNode = root.getChild();
-    testJsonSerDerObject(projectionNode);
     testCloneLogicalNode(projectionNode);
 
     // projection column test

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenContext.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenContext.java b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenContext.java
index ca3466b..0dea104 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenContext.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenContext.java
@@ -116,7 +116,7 @@ public class EvalCodeGenContext extends TajoGeneratorAdapter {
       if (entry.getKey().getType() == EvalType.CONST) {
         ConstEval constEval = (ConstEval) entry.getKey();
 
-        if (constEval.getValueType().getType() == TajoDataTypes.Type.INTERVAL) {
+        if (constEval.getValueType().baseType() == TajoDataTypes.Type.INTERVAL) {
           IntervalDatum datum = (IntervalDatum) constEval.getValue();
 
           final String internalName = TajoGeneratorAdapter.getInternalName(IntervalDatum.class);

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenerator.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenerator.java b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenerator.java
index 1bf0d57..5ee6d82 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenerator.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/EvalCodeGenerator.java
@@ -20,7 +20,6 @@ package org.apache.tajo.engine.codegen;
 
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.datum.IntervalDatum;
 import org.apache.tajo.datum.ProtobufDatum;
@@ -36,7 +35,6 @@ import java.io.PrintStream;
 import java.lang.reflect.Constructor;
 import java.util.Stack;
 
-import static org.apache.tajo.common.TajoDataTypes.DataType;
 import static org.apache.tajo.engine.codegen.TajoGeneratorAdapter.getDescription;
 import static org.apache.tajo.plan.expr.FunctionEval.ParamType;
 
@@ -172,7 +170,7 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
       context.emitNullityCheck(ifNull);
 
       SignedEval signed = (SignedEval) unary;
-      switch (signed.getValueType().getType()) {
+      switch (signed.getValueType().baseType()) {
       case BOOLEAN:
       case CHAR:
       case INT1:
@@ -322,8 +320,8 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
   }
 
   public EvalNode visitCast(EvalCodeGenContext context, Stack<EvalNode> stack, CastEval cast) {
-    DataType  srcType = cast.getOperand().getValueType();
-    DataType targetType = cast.getValueType();
+    org.apache.tajo.type.Type srcType = cast.getOperand().getValueType();
+    org.apache.tajo.type.Type targetType = cast.getValueType();
 
     if (srcType.equals(targetType)) {
       visit(context, cast.getChild(), stack);
@@ -351,7 +349,7 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
 
   public EvalNode visitField(EvalCodeGenContext context, FieldEval field, Stack<EvalNode> stack) {
 
-    if (field.getValueType().getType() == TajoDataTypes.Type.NULL_TYPE) {
+    if (field.getValueType().isNull()) {
       context.pushNullOfThreeValuedLogic();
       context.pushNullFlag(false);
     } else {
@@ -377,7 +375,7 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
       String methodName = null;
       Class returnType = null;
       Class [] paramTypes = null;
-      switch (field.getValueType().getType()) {
+      switch (field.getValueType().baseType()) {
       case BOOLEAN:
         methodName = "getByte";
         returnType = byte.class;
@@ -480,8 +478,8 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
     return evalNode;
   }
 
-  public static int store(EvalCodeGenContext context, DataType type, int idx) {
-    switch (type.getType()) {
+  public static int store(EvalCodeGenContext context, org.apache.tajo.type.Type type, int idx) {
+    switch (type.baseType()) {
     case NULL_TYPE:
     case BOOLEAN:
     case CHAR:
@@ -536,10 +534,10 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
   public EvalNode visitComparisonEval(EvalCodeGenContext context, BinaryEval evalNode, Stack<EvalNode> stack)
       throws CompilationError {
 
-    DataType lhsType = evalNode.getLeftExpr().getValueType();
-    DataType rhsType = evalNode.getRightExpr().getValueType();
+    org.apache.tajo.type.Type lhsType = evalNode.getLeftExpr().getValueType();
+    org.apache.tajo.type.Type rhsType = evalNode.getRightExpr().getValueType();
 
-    if (lhsType.getType() == TajoDataTypes.Type.NULL_TYPE || rhsType.getType() == TajoDataTypes.Type.NULL_TYPE) {
+    if (lhsType.isNull() || rhsType.isNull()) {
       context.pushNullOfThreeValuedLogic();
       context.pushNullFlag(false);
     } else {
@@ -644,7 +642,7 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
 
   @Override
   public EvalNode visitConst(EvalCodeGenContext context, ConstEval constEval, Stack<EvalNode> stack) {
-    switch (constEval.getValueType().getType()) {
+    switch (constEval.getValueType().baseType()) {
     case NULL_TYPE:
 
       if (stack.isEmpty()) {
@@ -697,11 +695,10 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
       emitGetField(context, context.owner, context.symbols.get(constEval), IntervalDatum.class);
       break;
     default:
-      throw new UnsupportedOperationException(constEval.getValueType().getType().name() +
-          " const type is not supported");
+      throw new UnsupportedOperationException(constEval.getValueType() + " const type is not supported");
     }
 
-    context.pushNullFlag(constEval.getValueType().getType() != TajoDataTypes.Type.NULL_TYPE);
+    context.pushNullFlag(!constEval.getValueType().isNull());
     return constEval;
   }
 
@@ -709,7 +706,7 @@ public class EvalCodeGenerator extends SimpleEvalNodeVisitor<EvalCodeGenContext>
     ParamType[] paramTypes = new ParamType[arguments.length];
     for (int i = 0; i < arguments.length; i++) {
       if (arguments[i].getType() == EvalType.CONST) {
-        if (arguments[i].getValueType().getType() == TajoDataTypes.Type.NULL_TYPE) {
+        if (arguments[i].getValueType().isNull()) {
           paramTypes[i] = ParamType.NULL;
         } else {
           paramTypes[i] = ParamType.CONSTANT;

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ScalarFunctionBindingEmitter.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ScalarFunctionBindingEmitter.java b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ScalarFunctionBindingEmitter.java
index b33a7c4..9f022ce 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ScalarFunctionBindingEmitter.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/ScalarFunctionBindingEmitter.java
@@ -26,6 +26,7 @@ import org.apache.tajo.org.objectweb.asm.Label;
 import org.apache.tajo.org.objectweb.asm.Opcodes;
 import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.plan.expr.FunctionEval;
+import org.apache.tajo.type.Type;
 
 import java.util.Stack;
 
@@ -114,7 +115,7 @@ public class ScalarFunctionBindingEmitter {
     }
   }
 
-  private static void emitFunctionReturnValue(EvalCodeGenContext context, TajoDataTypes.DataType returnType,
+  private static void emitFunctionReturnValue(EvalCodeGenContext context, Type returnType,
                                        StaticMethodInvocationDesc method) {
     if (FunctionUtil.isNullableParam(method.getReturnClass())) {
       Label ifNull = new Label();
@@ -145,7 +146,7 @@ public class ScalarFunctionBindingEmitter {
     context.istore(nullFlagId);
   }
 
-  private static void emitBoxedParameter(EvalCodeGenContext context, TajoDataTypes.DataType dataType) {
+  private static void emitBoxedParameter(EvalCodeGenContext context, Type dataType) {
     Label ifNull = new Label();
     Label afterAll = new Label();
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-core/src/main/java/org/apache/tajo/engine/codegen/TajoGeneratorAdapter.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/TajoGeneratorAdapter.java b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/TajoGeneratorAdapter.java
index b1a15ae..8a958bb 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/TajoGeneratorAdapter.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/TajoGeneratorAdapter.java
@@ -33,6 +33,7 @@ import org.apache.tajo.org.objectweb.asm.commons.GeneratorAdapter;
 import org.apache.tajo.org.objectweb.asm.commons.TableSwitchGenerator;
 import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.plan.expr.EvalType;
+import org.apache.tajo.type.Char;
 import org.apache.tajo.util.TUtil;
 import org.apache.tajo.util.datetime.DateTimeUtil;
 
@@ -160,13 +161,14 @@ class TajoGeneratorAdapter {
     generatorAdapter = new GeneratorAdapter(methodVisitor, access, name, desc);
   }
 
-  public static boolean isJVMInternalInt(TajoDataTypes.DataType dataType) {
-    TajoDataTypes.Type type = dataType.getType();
-    return type == BOOLEAN || type == INT1 || type == INT2 || type == INT4 || type== INET4;
+  public static boolean isJVMInternalInt(org.apache.tajo.type.Type type) {
+    final TajoDataTypes.Type baseType = type.baseType();
+    return baseType == BOOLEAN || baseType == INT1 || baseType == INT2 || baseType == INT4 || baseType== INET4;
   }
 
-  public static int getWordSize(TajoDataTypes.DataType type) {
-    if (type.getType() == INT8 || type.getType() == FLOAT8 || type.getType() == TIMESTAMP || type.getType() == TIME) {
+  public static int getWordSize(org.apache.tajo.type.Type type) {
+    final TajoDataTypes.Type baseType = type.baseType();
+    if (baseType == INT8 || baseType == FLOAT8 || baseType == TIMESTAMP || baseType == TIME) {
       return 2;
     } else {
       return 1;
@@ -220,9 +222,9 @@ class TajoGeneratorAdapter {
     methodvisitor.visitLdcInsn(value);
   }
 
-  public void ifCmp(TajoDataTypes.DataType dataType, EvalType evalType, Label elseLabel) {
+  public void ifCmp(org.apache.tajo.type.Type type, EvalType evalType, Label elseLabel) {
 
-    if (isJVMInternalInt(dataType)) {
+    if (isJVMInternalInt(type)) {
       switch (evalType) {
       case EQUAL:
         methodvisitor.visitJumpInsn(Opcodes.IF_ICMPNE, elseLabel);
@@ -247,10 +249,10 @@ class TajoGeneratorAdapter {
       }
     } else {
 
-      if (dataType.getType() == TEXT) {
+      if (type.baseType() == TEXT) {
         invokeVirtual(String.class, "compareTo", int.class, new Class[]{String.class});
       } else {
-        int opCode = TajoGeneratorAdapter.getOpCode(evalType, dataType);
+        int opCode = TajoGeneratorAdapter.getOpCode(evalType, type);
         methodvisitor.visitInsn(opCode);
       }
 
@@ -279,8 +281,8 @@ class TajoGeneratorAdapter {
     }
   }
 
-  public void load(TajoDataTypes.DataType dataType, int idx) {
-    switch (dataType.getType()) {
+  public void load(org.apache.tajo.type.Type type, int idx) {
+    switch (type.baseType()) {
     case NULL_TYPE:
     case BOOLEAN:
     case CHAR:
@@ -305,7 +307,7 @@ class TajoGeneratorAdapter {
       methodvisitor.visitVarInsn(Opcodes.ALOAD, idx);
       break;
     default:
-      throw new CompilationError("Unknown data type: " + dataType.getType().name());
+      throw new CompilationError("Unknown data type: " + type);
     }
   }
 
@@ -398,20 +400,22 @@ class TajoGeneratorAdapter {
     emitNullityCheck(ifNull);
   }
 
-  public void pushDummyValue(TajoDataTypes.DataType type) {
-    if (type.getType() == NULL_TYPE) {
+  public void pushDummyValue(org.apache.tajo.type.Type type) {
+    TajoDataTypes.Type baseType = type.baseType();
+
+    if (type.isNull()) {
       pushNullOfThreeValuedLogic();
-    } else if (isJVMInternalInt(type) || type.getType() == DATE) {
+    } else if (isJVMInternalInt(type) || baseType == DATE) {
       push(0);
-    } else if (type.getType() == TajoDataTypes.Type.INT8 || type.getType() == TIMESTAMP || type.getType() == TIME) {
+    } else if (baseType == INT8 || baseType == TIMESTAMP || baseType == TIME) {
       push(0L);
-    } else if (type.getType() == TajoDataTypes.Type.FLOAT8) {
+    } else if (baseType == FLOAT8) {
       push(0.0d);
-    } else if (type.getType() == TajoDataTypes.Type.FLOAT4) {
+    } else if (baseType == FLOAT4) {
       push(0.0f);
-    } else if (type.getType() == TajoDataTypes.Type.CHAR || type.getType() == TajoDataTypes.Type.TEXT) {
+    } else if (baseType == CHAR || baseType == TEXT) {
       push("");
-    } else if (type.getType() == INTERVAL || type.getType() == PROTOBUF) {
+    } else if (baseType == INTERVAL || baseType == PROTOBUF) {
       invokeStatic(NullDatum.class, "get", NullDatum.class, new Class[]{});
     } else {
       assert false;
@@ -443,25 +447,26 @@ class TajoGeneratorAdapter {
         getMethodDescription(returnType, paramTypes));
   }
 
-  public static boolean isPrimitiveOpCode(EvalType evalType, TajoDataTypes.DataType returnType) {
-    return TUtil.containsInNestedMap(OpCodesMap, evalType, returnType.getType());
+  public static boolean isPrimitiveOpCode(EvalType evalType, org.apache.tajo.type.Type returnType) {
+    return TUtil.containsInNestedMap(OpCodesMap, evalType, returnType.baseType());
   }
 
-  public static int getOpCode(EvalType evalType, TajoDataTypes.DataType returnType) {
+  public static int getOpCode(EvalType evalType, org.apache.tajo.type.Type returnType) {
     if (!isPrimitiveOpCode(evalType, returnType)) {
-      throw new CompilationError("No Such OpCode for " + evalType + " returning " + returnType.getType().name());
+      throw new CompilationError("No Such OpCode for " + evalType + " returning " + returnType);
     }
-    return TUtil.getFromNestedMap(OpCodesMap, evalType, returnType.getType());
+    return TUtil.getFromNestedMap(OpCodesMap, evalType, returnType.baseType());
   }
 
-  public void castInsn(TajoDataTypes.DataType srcType, TajoDataTypes.DataType targetType) {
-    TajoDataTypes.Type srcRawType = srcType.getType();
-    TajoDataTypes.Type targetRawType = targetType.getType();
-    switch(srcRawType) {
+  public void castInsn(org.apache.tajo.type.Type srcType, org.apache.tajo.type.Type targetType) {
+    TajoDataTypes.Type srcBaseType = srcType.baseType();
+    TajoDataTypes.Type targetBaseType = targetType.baseType();
+    switch(srcBaseType) {
     case BOOLEAN:
     case CHAR: {
-      if (srcType.hasLength() && srcType.getLength() == 1) {
-        switch (targetType.getType()) {
+      Char srcCharType = (Char) srcType;
+      if (srcCharType.length() == 1) {
+        switch (targetBaseType) {
         case CHAR:
         case INT1:
         case INT2:
@@ -474,7 +479,7 @@ class TajoGeneratorAdapter {
           throw new TajoRuntimeException(new InvalidValueForCastException(srcType, targetType));
         }
       } else {
-        switch (targetRawType) {
+        switch (targetBaseType) {
         case CHAR:
         case INT1:
         case INT2:
@@ -491,7 +496,7 @@ class TajoGeneratorAdapter {
     case INT1:
     case INT2:
     case INT4:
-      switch (targetType.getType()) {
+      switch (targetBaseType) {
       case CHAR:
       case INT1: methodvisitor.visitInsn(Opcodes.I2C); break;
       case INT2: methodvisitor.visitInsn(Opcodes.I2S); break;
@@ -504,7 +509,7 @@ class TajoGeneratorAdapter {
       }
       break;
     case INT8:
-      switch (targetRawType) {
+      switch (targetBaseType) {
       case CHAR:
       case INT1:
       case INT2:
@@ -517,7 +522,7 @@ class TajoGeneratorAdapter {
       }
       break;
     case FLOAT4:
-      switch (targetRawType) {
+      switch (targetBaseType) {
       case CHAR:
       case INT1:
       case INT2:
@@ -530,7 +535,7 @@ class TajoGeneratorAdapter {
       }
       break;
     case FLOAT8:
-      switch (targetRawType) {
+      switch (targetBaseType) {
       case CHAR:
       case INT1:
       case INT2:
@@ -543,7 +548,7 @@ class TajoGeneratorAdapter {
       }
       break;
     case TEXT:
-      switch (targetRawType) {
+      switch (targetBaseType) {
       case CHAR:
       case INT1:
       case INT2:
@@ -582,7 +587,7 @@ class TajoGeneratorAdapter {
     return clazz.getName().replace('.', '/');
   }
 
-  public void convertToPrimitive(TajoDataTypes.DataType type) {
+  public void convertToPrimitive(org.apache.tajo.type.Type type) {
 
     Label ifNull = new Label();
     Label afterAll = new Label();
@@ -595,7 +600,7 @@ class TajoGeneratorAdapter {
     methodvisitor.visitJumpInsn(Opcodes.IFEQ, ifNull);  // datum
 
     aload(datum);
-    switch (type.getType()) {
+    switch (type.baseType()) {
     case BOOLEAN:
     case INT1:
     case INT2:
@@ -634,11 +639,11 @@ class TajoGeneratorAdapter {
     methodvisitor.visitLabel(afterAll);
   }
 
-  public void convertToDatum(TajoDataTypes.DataType type, boolean castToDatum) {
+  public void convertToDatum(org.apache.tajo.type.Type type, boolean castToDatum) {
     String convertMethod;
     Class returnType;
     Class [] paramTypes;
-    switch (type.getType()) {
+    switch (type.baseType()) {
     case NULL_TYPE:
       pop();      // pop null flag
       pop(type);  // pop null datum
@@ -716,7 +721,7 @@ class TajoGeneratorAdapter {
       paramTypes = new Class[] {int.class};
       break;
     default:
-      throw new RuntimeException("Unsupported type: " + type.getType().name());
+      throw new RuntimeException("Unsupported type: " + type);
     }
 
     Label ifNull = new Label();
@@ -738,7 +743,7 @@ class TajoGeneratorAdapter {
     }
   }
 
-  public void pop(TajoDataTypes.DataType type) {
+  public void pop(org.apache.tajo.type.Type type) {
     if (getWordSize(type) == 2) {
       methodvisitor.visitInsn(Opcodes.POP2);
     } else {
@@ -886,11 +891,11 @@ class TajoGeneratorAdapter {
     return varId;
   }
 
-  public int store(TajoDataTypes.DataType type) {
+  public int store(org.apache.tajo.type.Type type) {
     int varId = nextVarId;
     nextVarId += TajoGeneratorAdapter.getWordSize(type);
 
-    switch (type.getType()) {
+    switch (type.baseType()) {
     case NULL_TYPE:
     case BOOLEAN:
     case CHAR:
@@ -916,14 +921,14 @@ class TajoGeneratorAdapter {
       methodvisitor.visitVarInsn(Opcodes.ASTORE, varId);
       break;
     default:
-      throw new CompilationError("Unknown data type: " + type.getType().name());
+      throw new CompilationError("Unknown data type: " + type);
     }
 
     return varId;
   }
 
-  public void emitBoxing(EvalCodeGenContext context, TajoDataTypes.DataType dataType) {
-    switch (dataType.getType()) {
+  public void emitBoxing(EvalCodeGenContext context, org.apache.tajo.type.Type type) {
+    switch (type.baseType()) {
     case CHAR:
     case TEXT:
 
@@ -944,12 +949,12 @@ class TajoGeneratorAdapter {
       break;
 
     default:
-      throw new RuntimeException(dataType.getType().name() + " is not supported yet");
+      throw new RuntimeException(type + " is not supported yet");
     }
   }
 
-  public void emitUnboxing(EvalCodeGenContext context, TajoDataTypes.DataType dataType) {
-    switch (dataType.getType()) {
+  public void emitUnboxing(EvalCodeGenContext context, org.apache.tajo.type.Type type) {
+    switch (type.baseType()) {
     case CHAR:
     case TEXT:
 
@@ -970,7 +975,7 @@ class TajoGeneratorAdapter {
       break;
 
     default:
-      throw new RuntimeException(dataType.getType().name() + " is not supported yet");
+      throw new RuntimeException(type + " is not supported yet");
     }
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-core/src/main/java/org/apache/tajo/engine/codegen/VariablesPreBuilder.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/VariablesPreBuilder.java b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/VariablesPreBuilder.java
index 95ec371..9d0f9d0 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/codegen/VariablesPreBuilder.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/codegen/VariablesPreBuilder.java
@@ -55,9 +55,9 @@ class VariablesPreBuilder extends SimpleEvalNodeVisitor<EvalCodeGenContext> {
   @Override
   public EvalNode visitConst(EvalCodeGenContext context, ConstEval constEval, Stack<EvalNode> stack) {
 
-    if (constEval.getValueType().getType() == TajoDataTypes.Type.INTERVAL) {
+    if (constEval.getValueType().baseType() == TajoDataTypes.Type.INTERVAL) {
       if (!context.symbols.containsKey(constEval)) {
-        String fieldName = constEval.getValueType().getType().name() + "_" + context.seqId++;
+        String fieldName = constEval.getValueType().baseType().name() + "_" + context.seqId++;
         context.symbols.put(constEval, fieldName);
 
         context.classWriter.visitField(Opcodes.ACC_PRIVATE, fieldName,

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/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 463d015..cdab04f 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
@@ -349,13 +349,13 @@ public class GlobalPlanner {
   private AggregationFunctionCallEval createSumFunction(EvalNode[] args) throws TajoException {
     FunctionDesc functionDesc = null;
     functionDesc = getCatalog().getFunction("sum", CatalogProtos.FunctionType.AGGREGATION,
-        args[0].getValueType());
+        TypeConverter.convert(args[0].getValueType()));
     return new AggregationFunctionCallEval(functionDesc, args);
   }
 
   private AggregationFunctionCallEval createCountFunction(EvalNode [] args) throws TajoException {
     FunctionDesc functionDesc = getCatalog().getFunction("count", CatalogProtos.FunctionType.AGGREGATION,
-        args[0].getValueType());
+        TypeConverter.convert(args[0].getValueType()));
     return new AggregationFunctionCallEval(functionDesc, args);
   }
 
@@ -367,13 +367,13 @@ public class GlobalPlanner {
 
   private AggregationFunctionCallEval createMaxFunction(EvalNode [] args) throws TajoException {
     FunctionDesc functionDesc = getCatalog().getFunction("max", CatalogProtos.FunctionType.AGGREGATION,
-        args[0].getValueType());
+        TypeConverter.convert(args[0].getValueType()));
     return new AggregationFunctionCallEval(functionDesc, args);
   }
 
   private AggregationFunctionCallEval createMinFunction(EvalNode [] args) throws TajoException {
     FunctionDesc functionDesc = getCatalog().getFunction("min", CatalogProtos.FunctionType.AGGREGATION,
-        args[0].getValueType());
+        TypeConverter.convert(args[0].getValueType()));
     return new AggregationFunctionCallEval(functionDesc, args);
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/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 d55c4ba..660f875 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
@@ -32,6 +32,7 @@ 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.exception.TajoException;
+import org.apache.tajo.exception.UnsupportedException;
 import org.apache.tajo.plan.expr.EvalNode;
 import org.apache.tajo.plan.logical.LogicalNode;
 import org.apache.tajo.util.Pair;
@@ -58,7 +59,6 @@ public class ExecutionBlockSharedResource {
     if (!initializing.getAndSet(true)) {
       try {
         ExecutionBlockSharedResource.this.context = context;
-        initPlan(planJson);
         initCodeGeneration();
         resourceInitSuccess = true;
       } catch (Throwable t) {
@@ -72,10 +72,6 @@ public class ExecutionBlockSharedResource {
     }
   }
 
-  private void initPlan(String planJson) {
-    plan = CoreGsonHelper.fromJson(planJson, LogicalNode.class);
-  }
-
   private void initCodeGeneration() throws TajoException {
     if (context.getBool(SessionVars.CODEGEN)) {
       codeGenEnabled = true;

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/ExprAnnotator.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/ExprAnnotator.java b/tajo-plan/src/main/java/org/apache/tajo/plan/ExprAnnotator.java
index 8107c72..e87d33b 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/ExprAnnotator.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/ExprAnnotator.java
@@ -23,17 +23,10 @@ import org.apache.commons.collections.set.UnmodifiableSet;
 import org.apache.tajo.OverridableConf;
 import org.apache.tajo.SessionVars;
 import org.apache.tajo.algebra.*;
-import org.apache.tajo.catalog.CatalogService;
-import org.apache.tajo.catalog.CatalogUtil;
-import org.apache.tajo.catalog.Column;
-import org.apache.tajo.catalog.FunctionDesc;
-import org.apache.tajo.exception.UndefinedFunctionException;
+import org.apache.tajo.catalog.*;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.datum.*;
-import org.apache.tajo.exception.TajoException;
-import org.apache.tajo.exception.TajoInternalError;
-import org.apache.tajo.exception.NotImplementedException;
-import org.apache.tajo.exception.UnsupportedException;
+import org.apache.tajo.exception.*;
 import org.apache.tajo.plan.algebra.BaseAlgebraVisitor;
 import org.apache.tajo.plan.expr.*;
 import org.apache.tajo.plan.logical.NodeType;
@@ -52,6 +45,7 @@ import java.util.TimeZone;
 
 import static org.apache.tajo.algebra.WindowSpec.WindowFrameEndBoundType;
 import static org.apache.tajo.algebra.WindowSpec.WindowFrameStartBoundType;
+import static org.apache.tajo.catalog.TypeConverter.convert;
 import static org.apache.tajo.catalog.proto.CatalogProtos.FunctionType;
 import static org.apache.tajo.common.TajoDataTypes.DataType;
 import static org.apache.tajo.common.TajoDataTypes.Type;
@@ -115,8 +109,8 @@ public class ExprAnnotator extends BaseAlgebraVisitor<ExprAnnotator.Context, Eva
    * @return a pair including left/right hand side terms
    */
   private static Pair<EvalNode, EvalNode> convertTypesIfNecessary(Context ctx, EvalNode lhs, EvalNode rhs) {
-    Type lhsType = lhs.getValueType().getType();
-    Type rhsType = rhs.getValueType().getType();
+    Type lhsType = lhs.getValueType().baseType();
+    Type rhsType = rhs.getValueType().baseType();
 
     // If one of both is NULL, it just returns the original types without casting.
     if (lhsType == Type.NULL_TYPE || rhsType == Type.NULL_TYPE) {
@@ -148,11 +142,11 @@ public class ExprAnnotator extends BaseAlgebraVisitor<ExprAnnotator.Context, Eva
   private static EvalNode convertType(Context ctx, EvalNode evalNode, DataType toType) {
 
     // if original and toType is the same, we don't need type conversion.
-    if (evalNode.getValueType().equals(toType)) {
+    if (evalNode.getValueType().equals(TypeConverter.convert(toType))) {
       return evalNode;
     }
     // the conversion to null is not allowed.
-    if (evalNode.getValueType().getType() == Type.NULL_TYPE || toType.getType() == Type.NULL_TYPE) {
+    if (evalNode.getValueType().isNull() || toType.getType() == Type.NULL_TYPE) {
       return evalNode;
     }
 
@@ -314,7 +308,10 @@ public class ExprAnnotator extends BaseAlgebraVisitor<ExprAnnotator.Context, Eva
     stack.pop();
 
     // implicit type conversion
-    DataType widestType = CatalogUtil.getWidestType(predicand.getValueType(), begin.getValueType(), end.getValueType());
+    DataType widestType = CatalogUtil.getWidestType(
+        convert(predicand.getValueType()),
+        convert(begin.getValueType()),
+        convert(end.getValueType()));
 
     BetweenPredicateEval betweenEval = new BetweenPredicateEval(
         between.isNot(),
@@ -343,13 +340,15 @@ public class ExprAnnotator extends BaseAlgebraVisitor<ExprAnnotator.Context, Eva
     }
 
     // Getting the widest type from all if-then expressions and else expression.
-    DataType widestType = caseWhenEval.getIfThenEvals().get(0).getResult().getValueType();
+    DataType widestType = convert(caseWhenEval.getIfThenEvals().get(0).getResult().getValueType());
     for (int i = 1; i < caseWhenEval.getIfThenEvals().size(); i++) {
-      widestType = CatalogUtil.getWidestType(caseWhenEval.getIfThenEvals().get(i).getResult().getValueType(),
+      widestType = CatalogUtil.getWidestType(
+          convert(caseWhenEval.getIfThenEvals().get(i).getResult().getValueType()),
           widestType);
     }
     if (caseWhen.hasElseResult()) {
-      widestType = CatalogUtil.getWidestType(widestType, caseWhenEval.getElse().getValueType());
+      widestType = CatalogUtil.getWidestType(
+          widestType, convert(caseWhenEval.getElse().getValueType()));
     }
 
     assertEval(widestType != null, "Invalid Type Conversion for CaseWhen");
@@ -437,10 +436,10 @@ public class ExprAnnotator extends BaseAlgebraVisitor<ExprAnnotator.Context, Eva
     EvalNode rhs = visit(ctx, stack, expr.getRight());
     stack.pop();
 
-    if (lhs.getValueType().getType() != Type.TEXT) {
+    if (lhs.getValueType().baseType() != Type.TEXT) {
       lhs = convertType(ctx, lhs, CatalogUtil.newSimpleDataType(Type.TEXT));
     }
-    if (rhs.getValueType().getType() != Type.TEXT) {
+    if (rhs.getValueType().baseType() != Type.TEXT) {
       rhs = convertType(ctx, rhs, CatalogUtil.newSimpleDataType(Type.TEXT));
     }
 
@@ -585,7 +584,7 @@ public class ExprAnnotator extends BaseAlgebraVisitor<ExprAnnotator.Context, Eva
 
     for (int i = 0; i < params.length; i++) {
       givenArgs[i] = visit(ctx, stack, params[i]);
-      paramTypes[i] = givenArgs[i].getValueType();
+      paramTypes[i] = TypeConverter.convert(givenArgs[i].getValueType());
     }
 
     stack.pop(); // <--- Pop
@@ -662,7 +661,7 @@ public class ExprAnnotator extends BaseAlgebraVisitor<ExprAnnotator.Context, Eva
     if (setFunction.getSignature().equalsIgnoreCase("count")) {
       paramTypes[0] = CatalogUtil.newSimpleDataType(Type.ANY);
     } else {
-      paramTypes[0] = givenArgs[0].getValueType();
+      paramTypes[0] = TypeConverter.convert(givenArgs[0].getValueType());
     }
 
     if (!catalog.containFunction(setFunction.getSignature(), functionType, paramTypes)) {
@@ -719,11 +718,11 @@ public class ExprAnnotator extends BaseAlgebraVisitor<ExprAnnotator.Context, Eva
       } else if (windowFunc.getSignature().equalsIgnoreCase("row_number")) {
         paramTypes[0] = CatalogUtil.newSimpleDataType(Type.INT8);
       } else {
-        paramTypes[0] = givenArgs[0].getValueType();
+        paramTypes[0] = convert(givenArgs[0].getValueType());
       }
       for (int i = 1; i < params.length; i++) {
         givenArgs[i] = visit(ctx, stack, params[i]);
-        paramTypes[i] = givenArgs[i].getValueType();
+        paramTypes[i] = convert(givenArgs[i].getValueType());
       }
     } else {
       if (windowFunc.getSignature().equalsIgnoreCase("rank")) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/LogicalPlanner.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/LogicalPlanner.java b/tajo-plan/src/main/java/org/apache/tajo/plan/LogicalPlanner.java
index 9176c2f..f74e16f 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/LogicalPlanner.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/LogicalPlanner.java
@@ -577,7 +577,7 @@ public class LogicalPlanner extends BaseAlgebraVisitor<LogicalPlanner.PlanContex
   public static void prohibitNestedRecordProjection(Projectable projectable)
       throws TajoException {
     for (Target t : projectable.getTargets()) {
-      if (t.getEvalTree().getValueType().getType() == TajoDataTypes.Type.RECORD) {
+      if (t.getEvalTree().getValueType().isStruct()) {
         throw new NotImplementedException("record field projection");
       }
     }

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/NamedExprsManager.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/NamedExprsManager.java b/tajo-plan/src/main/java/org/apache/tajo/plan/NamedExprsManager.java
index 6ad9d70..53f2610 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/NamedExprsManager.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/NamedExprsManager.java
@@ -34,6 +34,8 @@ import org.apache.tajo.util.TUtil;
 
 import java.util.*;
 
+import static org.apache.tajo.catalog.TypeConverter.convert;
+
 /**
  * NamedExprsManager manages an expressions used in a query block. All expressions used in a query block must be
  * added to NamedExprsManager. When an expression is added to NamedExprsManager, NamedExprsManager gives a reference
@@ -313,14 +315,14 @@ public class NamedExprsManager {
       // But, if this reference name is not primary name, it cannot use the reference name.
       // It changes the given reference name to the primary name.
       if (evalNode.getType() != EvalType.CONST && isEvaluated(normalized) && !isPrimaryName(refId, referenceName)) {
-        return new Target(new FieldEval(getPrimaryName(refId),evalNode.getValueType()), referenceName);
+        return new Target(new FieldEval(getPrimaryName(refId), convert(evalNode.getValueType())), referenceName);
       }
 
       EvalNode referredEval;
       if (evalNode.getType() == EvalType.CONST) {
         referredEval = evalNode;
       } else {
-        referredEval = new FieldEval(idToNamesMap.get(refId).get(0), evalNode.getValueType());
+        referredEval = new FieldEval(idToNamesMap.get(refId).get(0), convert(evalNode.getValueType()));
       }
       return new Target(referredEval, referenceName);
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/TypeDeterminant.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/TypeDeterminant.java b/tajo-plan/src/main/java/org/apache/tajo/plan/TypeDeterminant.java
index 1ff297f..9fc5c0d 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/TypeDeterminant.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/TypeDeterminant.java
@@ -25,18 +25,20 @@ import org.apache.tajo.catalog.CatalogService;
 import org.apache.tajo.catalog.CatalogUtil;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.FunctionDesc;
-import org.apache.tajo.exception.UndefinedFunctionException;
 import org.apache.tajo.catalog.proto.CatalogProtos;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.exception.TajoException;
 import org.apache.tajo.exception.TajoInternalError;
+import org.apache.tajo.exception.UndefinedFunctionException;
 import org.apache.tajo.function.FunctionUtil;
 import org.apache.tajo.plan.nameresolver.NameResolver;
 import org.apache.tajo.plan.nameresolver.NameResolvingMode;
 import org.apache.tajo.plan.visitor.SimpleAlgebraVisitor;
+import org.apache.tajo.type.Type;
 
 import java.util.Stack;
 
+import static org.apache.tajo.catalog.TypeConverter.convert;
 import static org.apache.tajo.common.TajoDataTypes.DataType;
 import static org.apache.tajo.common.TajoDataTypes.Type.BOOLEAN;
 import static org.apache.tajo.common.TajoDataTypes.Type.NULL_TYPE;
@@ -81,24 +83,24 @@ public class TypeDeterminant extends SimpleAlgebraVisitor<LogicalPlanner.PlanCon
     DataType lhsType = visit(ctx, stack, expr.getLeft());
     DataType rhsType = visit(ctx, stack, expr.getRight());
     stack.pop();
-    return computeBinaryType(expr.getType(), lhsType, rhsType);
+    return convert(computeBinaryType(expr.getType(), convert(lhsType), convert(rhsType)));
   }
 
-  public DataType computeBinaryType(OpType type, DataType lhsDataType, DataType rhsDataType) throws TajoException {
+  public Type computeBinaryType(OpType type, Type lhsDataType, Type rhsDataType) throws TajoException {
     Preconditions.checkNotNull(type);
     Preconditions.checkNotNull(lhsDataType);
     Preconditions.checkNotNull(rhsDataType);
 
     if(OpType.isLogicalType(type) || OpType.isComparisonType(type)) {
-      return BOOL_TYPE;
+      return Type.Bool;
     } else if (OpType.isArithmeticType(type)) {
       return DataTypeUtil.determineType(lhsDataType, rhsDataType);
     } else if (type == OpType.Concatenate) {
-      return CatalogUtil.newSimpleDataType(TajoDataTypes.Type.TEXT);
+      return Type.Text;
     } else if (type == OpType.InPredicate) {
-      return BOOL_TYPE;
+      return Type.Bool;
     } else if (type == OpType.LikePredicate || type == OpType.SimilarToPredicate || type == OpType.Regexp) {
-      return BOOL_TYPE;
+      return Type.Bool;
     } else {
       throw new TajoInternalError(type.name() + "is not binary type");
     }

http://git-wip-us.apache.org/repos/asf/tajo/blob/552376a8/tajo-plan/src/main/java/org/apache/tajo/plan/expr/AggregationFunctionCallEval.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/AggregationFunctionCallEval.java b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/AggregationFunctionCallEval.java
index 3ff0065..908496b 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/expr/AggregationFunctionCallEval.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/expr/AggregationFunctionCallEval.java
@@ -21,12 +21,13 @@ package org.apache.tajo.plan.expr;
 import com.google.gson.annotations.Expose;
 import org.apache.tajo.catalog.FunctionDesc;
 import org.apache.tajo.catalog.Schema;
-import org.apache.tajo.common.TajoDataTypes.DataType;
+import org.apache.tajo.catalog.TypeConverter;
 import org.apache.tajo.datum.Datum;
 import org.apache.tajo.plan.function.AggFunctionInvoke;
 import org.apache.tajo.plan.function.FunctionContext;
 import org.apache.tajo.plan.function.FunctionInvokeContext;
 import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.type.Type;
 import org.apache.tajo.util.TUtil;
 
 import java.io.IOException;
@@ -106,11 +107,11 @@ public class AggregationFunctionCallEval extends FunctionEval implements Cloneab
   }
 
   @Override
-  public DataType getValueType() {
+  public Type getValueType() {
     if (!lastPhase) {
-      return functionInvoke.getPartialResultType();
+      return TypeConverter.convert(functionInvoke.getPartialResultType());
     } else {
-      return funcDesc.getReturnType();
+      return TypeConverter.convert(funcDesc.getReturnType());
     }
   }
 


Mime
View raw message