carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [08/10] carbondata git commit: [CARBONDATA-1539] Change data type from enum to class
Date Fri, 13 Oct 2017 09:26:57 GMT
http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/converter/ThriftWrapperSchemaConverterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/converter/ThriftWrapperSchemaConverterImpl.java b/core/src/main/java/org/apache/carbondata/core/metadata/converter/ThriftWrapperSchemaConverterImpl.java
index bc877b7..6b2cb90 100644
--- a/core/src/main/java/org/apache/carbondata/core/metadata/converter/ThriftWrapperSchemaConverterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/converter/ThriftWrapperSchemaConverterImpl.java
@@ -23,6 +23,7 @@ import java.util.Map;
 
 import org.apache.carbondata.core.constants.CarbonCommonConstants;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.BucketingInfo;
 import org.apache.carbondata.core.metadata.schema.PartitionInfo;
@@ -122,33 +123,32 @@ public class ThriftWrapperSchemaConverterImpl implements SchemaConverter {
    * @return
    */
   private org.apache.carbondata.format.DataType fromWrapperToExternalDataType(DataType dataType) {
-
     if (null == dataType) {
       return null;
     }
-    switch (dataType) {
-      case STRING:
-        return org.apache.carbondata.format.DataType.STRING;
-      case INT:
-        return org.apache.carbondata.format.DataType.INT;
-      case SHORT:
-        return org.apache.carbondata.format.DataType.SHORT;
-      case LONG:
-        return org.apache.carbondata.format.DataType.LONG;
-      case DOUBLE:
-        return org.apache.carbondata.format.DataType.DOUBLE;
-      case DECIMAL:
-        return org.apache.carbondata.format.DataType.DECIMAL;
-      case DATE:
-        return org.apache.carbondata.format.DataType.DATE;
-      case TIMESTAMP:
-        return org.apache.carbondata.format.DataType.TIMESTAMP;
-      case ARRAY:
-        return org.apache.carbondata.format.DataType.ARRAY;
-      case STRUCT:
-        return org.apache.carbondata.format.DataType.STRUCT;
-      default:
-        return org.apache.carbondata.format.DataType.STRING;
+    // data type object maybe created by GSON, use id to compare the type instead of object address
+    if (dataType.getId() == DataTypes.STRING.getId()) {
+      return org.apache.carbondata.format.DataType.STRING;
+    } else if (dataType.getId() == DataTypes.INT.getId()) {
+      return org.apache.carbondata.format.DataType.INT;
+    } else if (dataType.getId() == DataTypes.SHORT.getId()) {
+      return org.apache.carbondata.format.DataType.SHORT;
+    } else if (dataType.getId() == DataTypes.LONG.getId()) {
+      return org.apache.carbondata.format.DataType.LONG;
+    } else if (dataType.getId() == DataTypes.DOUBLE.getId()) {
+      return org.apache.carbondata.format.DataType.DOUBLE;
+    } else if (dataType.getId() == DataTypes.DECIMAL.getId()) {
+      return org.apache.carbondata.format.DataType.DECIMAL;
+    } else if (dataType.getId() == DataTypes.DATE.getId()) {
+      return org.apache.carbondata.format.DataType.DATE;
+    } else if (dataType.getId() == DataTypes.TIMESTAMP.getId()) {
+      return org.apache.carbondata.format.DataType.TIMESTAMP;
+    } else if (dataType.getId() == DataTypes.ARRAY.getId()) {
+      return org.apache.carbondata.format.DataType.ARRAY;
+    } else if (dataType.getId() == DataTypes.STRUCT.getId()) {
+      return org.apache.carbondata.format.DataType.STRUCT;
+    } else {
+      return org.apache.carbondata.format.DataType.STRING;
     }
   }
 
@@ -362,27 +362,27 @@ public class ThriftWrapperSchemaConverterImpl implements SchemaConverter {
     }
     switch (dataType) {
       case STRING:
-        return DataType.STRING;
+        return DataTypes.STRING;
       case INT:
-        return DataType.INT;
+        return DataTypes.INT;
       case SHORT:
-        return DataType.SHORT;
+        return DataTypes.SHORT;
       case LONG:
-        return DataType.LONG;
+        return DataTypes.LONG;
       case DOUBLE:
-        return DataType.DOUBLE;
+        return DataTypes.DOUBLE;
       case DECIMAL:
-        return DataType.DECIMAL;
+        return DataTypes.DECIMAL;
       case TIMESTAMP:
-        return DataType.TIMESTAMP;
+        return DataTypes.TIMESTAMP;
       case DATE:
-        return DataType.DATE;
+        return DataTypes.DATE;
       case ARRAY:
-        return DataType.ARRAY;
+        return DataTypes.ARRAY;
       case STRUCT:
-        return DataType.STRUCT;
+        return DataTypes.STRUCT;
       default:
-        return DataType.STRING;
+        return DataTypes.STRING;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ArrayType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ArrayType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ArrayType.java
new file mode 100644
index 0000000..241d0f6
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ArrayType.java
@@ -0,0 +1,37 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class ArrayType extends DataType {
+
+  public static final DataType ARRAY = new ArrayType(DataTypes.ARRAY_TYPE_ID, 9, "ARRAY", -1);
+
+  private ArrayType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.ARRAY;
+  }
+
+  @Override
+  public boolean isComplexType() {
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/BooleanType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/BooleanType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/BooleanType.java
new file mode 100644
index 0000000..36cb84f
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/BooleanType.java
@@ -0,0 +1,33 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class BooleanType extends DataType {
+
+  public static final DataType BOOLEAN =
+      new BooleanType(DataTypes.BOOLEAN_TYPE_ID, 1, "BOOLEAN", 1);
+
+  private BooleanType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.BOOLEAN;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ByteArrayType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ByteArrayType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ByteArrayType.java
new file mode 100644
index 0000000..1f2872d
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ByteArrayType.java
@@ -0,0 +1,33 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class ByteArrayType extends DataType {
+
+  public static final DataType BYTE_ARRAY =
+      new ByteArrayType(DataTypes.BYTE_ARRAY_TYPE_ID, 13, "BYTE_ARRAY", -1);
+
+  private ByteArrayType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.BYTE_ARRAY;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ByteType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ByteType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ByteType.java
new file mode 100644
index 0000000..11138d2
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ByteType.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.carbondata.core.metadata.datatype;
+
+public class ByteType extends DataType {
+
+  public static final DataType BYTE = new ByteType(DataTypes.BYTE_TYPE_ID, 12, "BYTE", 1);
+
+  private ByteType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.BYTE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataType.java
index a37f265..b3dd1bc 100644
--- a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataType.java
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataType.java
@@ -17,46 +17,22 @@
 
 package org.apache.carbondata.core.metadata.datatype;
 
-public enum DataType {
-
-  STRING(0, "STRING", -1),
-  DATE(1, "DATE", -1),
-  TIMESTAMP(2, "TIMESTAMP", -1),
-  BOOLEAN(1, "BOOLEAN", 1),
-  SHORT(2, "SMALLINT", 2),
-  INT(3, "INT", 4),
-  FLOAT(4, "FLOAT", 4),
-  LONG(5, "BIGINT", 8),
-  DOUBLE(6, "DOUBLE", 8),
-  NULL(7, "NULL", 1),
-  DECIMAL(8, "DECIMAL", -1),
-  ARRAY(9, "ARRAY", -1),
-  STRUCT(10, "STRUCT", -1),
-  MAP(11, "MAP", -1),
-  BYTE(12, "BYTE", 1),
-  // internal use only, for variable length data type
-  BYTE_ARRAY(13, "BYTE_ARRAY", -1),
-  // internal use only, for value compression from integer/long to 3 bytes value
-  SHORT_INT(14, "SHORT_INT", 3),
-  // Only for internal use for backward compatability. It is only used for V1 version
-  LEGACY_LONG(15, "LEGACYBIGINT", 8);
+import java.io.Serializable;
 
-  public static final char DOUBLE_MEASURE_CHAR = 'n';
-  public static final char STRING_CHAR = 's';
-  public static final char TIMESTAMP_CHAR = 't';
-  public static final char DATE_CHAR = 'x';
-  public static final char BYTE_ARRAY_CHAR = 'y';
-  public static final char BYTE_VALUE_MEASURE_CHAR = 'c';
-  public static final char BIG_DECIMAL_MEASURE_CHAR = 'b';
-  public static final char BIG_INT_MEASURE_CHAR = 'd';
+public class DataType implements Serializable {
+
+  private static final long serialVersionUID = 19371726L;
 
+  // id is used for comparison and serialization/deserialization
+  private int id;
   private int precedenceOrder;
   private String name;
 
   // size of the value of this data type, negative value means variable length
   private int sizeInBytes;
 
-  DataType(int precedenceOrder, String name, int sizeInBytes) {
+  DataType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    this.id = id;
     this.precedenceOrder = precedenceOrder;
     this.name = name;
     this.sizeInBytes = sizeInBytes;
@@ -70,96 +46,70 @@ public enum DataType {
     return name;
   }
 
-  public boolean isComplexType() {
-    return precedenceOrder >= 9 && precedenceOrder <= 11;
-  }
-
   public int getSizeInBytes() {
     return sizeInBytes;
   }
 
   public int getSizeBits() {
-    if (this == SHORT_INT) {
-      throw new UnsupportedOperationException("Should not call this from datatype " + SHORT_INT);
-    }
     return (int) (Math.log(getSizeInBytes()) / Math.log(2));
   }
 
-  public static DataType valueOf(int ordinal) {
-    if (ordinal == STRING.ordinal()) {
-      return STRING;
-    } else if (ordinal == DATE.ordinal()) {
-      return DATE;
-    } else if (ordinal == TIMESTAMP.ordinal()) {
-      return TIMESTAMP;
-    } else if (ordinal == BOOLEAN.ordinal()) {
-      return BOOLEAN;
-    } else if (ordinal == SHORT.ordinal()) {
-      return SHORT;
-    } else if (ordinal == INT.ordinal()) {
-      return INT;
-    } else if (ordinal == FLOAT.ordinal()) {
-      return FLOAT;
-    } else if (ordinal == LONG.ordinal()) {
-      return LONG;
-    } else if (ordinal == DOUBLE.ordinal()) {
-      return DOUBLE;
-    } else if (ordinal == NULL.ordinal()) {
-      return NULL;
-    } else if (ordinal == DECIMAL.ordinal()) {
-      return DECIMAL;
-    } else if (ordinal == ARRAY.ordinal()) {
-      return ARRAY;
-    } else if (ordinal == STRUCT.ordinal()) {
-      return STRUCT;
-    } else if (ordinal == MAP.ordinal()) {
-      return MAP;
-    } else if (ordinal == BYTE.ordinal()) {
-      return BYTE;
-    } else if (ordinal == BYTE_ARRAY.ordinal()) {
-      return BYTE_ARRAY;
-    } else if (ordinal == SHORT_INT.ordinal()) {
-      return SHORT_INT;
-    } else {
-      throw new RuntimeException("create DataType with invalid ordinal: " + ordinal);
-    }
+  public int getId() {
+    return id;
   }
 
-  public static char convertType(DataType type) {
-    switch (type) {
-      case BYTE:
-      case SHORT:
-      case SHORT_INT:
-      case INT:
-      case LONG:
-        return BIG_INT_MEASURE_CHAR;
-      case DOUBLE:
-        return DOUBLE_MEASURE_CHAR;
-      case DECIMAL:
-        return BIG_DECIMAL_MEASURE_CHAR;
-      case STRING:
-        return STRING_CHAR;
-      case TIMESTAMP:
-        return TIMESTAMP_CHAR;
-      case DATE:
-        return DATE_CHAR;
-      case BYTE_ARRAY:
-        return BYTE_ARRAY_CHAR;
-      default:
-        throw new RuntimeException("Unexpected type: " + type);
+  public boolean isComplexType() {
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getName();
+  }
+
+  public static final char DOUBLE_MEASURE_CHAR = 'n';
+  public static final char STRING_CHAR = 's';
+  public static final char TIMESTAMP_CHAR = 't';
+  public static final char DATE_CHAR = 'x';
+  public static final char BYTE_ARRAY_CHAR = 'y';
+  public static final char BYTE_VALUE_MEASURE_CHAR = 'c';
+  public static final char BIG_DECIMAL_MEASURE_CHAR = 'b';
+  public static final char BIG_INT_MEASURE_CHAR = 'd';
+
+  public static char convertType(DataType dataType) {
+    if (dataType == DataTypes.BYTE ||
+        dataType == DataTypes.SHORT ||
+        dataType == DataTypes.SHORT_INT ||
+        dataType == DataTypes.INT ||
+        dataType == DataTypes.LONG) {
+      return BIG_INT_MEASURE_CHAR;
+    } else if (dataType == DataTypes.DOUBLE) {
+      return DOUBLE_MEASURE_CHAR;
+    } else if (dataType == DataTypes.DECIMAL) {
+      return BIG_DECIMAL_MEASURE_CHAR;
+    } else if (dataType == DataTypes.STRING) {
+      return STRING_CHAR;
+    } else if (dataType == DataTypes.TIMESTAMP) {
+      return TIMESTAMP_CHAR;
+    } else if (dataType == DataTypes.DATE) {
+      return DATE_CHAR;
+    } else if (dataType == DataTypes.BYTE_ARRAY) {
+      return BYTE_ARRAY_CHAR;
+    } else {
+      throw new RuntimeException("Unexpected type: " + dataType);
     }
   }
 
   public static DataType getDataType(char type) {
     switch (type) {
       case BIG_INT_MEASURE_CHAR:
-        return DataType.LONG;
+        return DataTypes.LONG;
       case DOUBLE_MEASURE_CHAR:
-        return DataType.DOUBLE;
+        return DataTypes.DOUBLE;
       case BIG_DECIMAL_MEASURE_CHAR:
-        return DataType.DECIMAL;
+        return DataTypes.DECIMAL;
       case 'l':
-        return DataType.LEGACY_LONG;
+        return DataTypes.LEGACY_LONG;
       default:
         throw new RuntimeException("Unexpected type: " + type);
     }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataTypes.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataTypes.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataTypes.java
new file mode 100644
index 0000000..178f06a
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DataTypes.java
@@ -0,0 +1,117 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+/**
+ * Holds all singleton object for all data type used in carbon
+ */
+public class DataTypes {
+
+  // singleton for each data type
+  public static final DataType STRING = StringType.STRING;
+  public static final DataType DATE = DateType.DATE;
+  public static final DataType TIMESTAMP = TimestampType.TIMESTAMP;
+  public static final DataType BOOLEAN = BooleanType.BOOLEAN;
+  public static final DataType SHORT = ShortType.SHORT;
+  public static final DataType INT = IntType.INT;
+  public static final DataType FLOAT = FloatType.FLOAT;
+  public static final DataType LONG = LongType.LONG;
+  public static final DataType DOUBLE = DoubleType.DOUBLE;
+  public static final DataType NULL = NullType.NULL;
+  public static final DataType BYTE = ByteType.BYTE;
+
+  // internal use only, for variable length data type
+  public static final DataType BYTE_ARRAY = ByteArrayType.BYTE_ARRAY;
+
+  // internal use only, for value compression from integer/long to 3 bytes value
+  public static final DataType SHORT_INT = ShortIntType.SHORT_INT;
+
+  // Only for internal use for backward compatability. It is only used for V1 version
+  public static final DataType LEGACY_LONG = LegacyLongType.LEGACY_LONG;
+
+  public static final DataType DECIMAL = DecimalType.DECIMAL;
+  public static final DataType ARRAY = ArrayType.ARRAY;
+  public static final DataType STRUCT = StructType.STRUCT;
+  public static final DataType MAP = MapType.MAP;
+
+  // these IDs are used within this package only
+  static final int STRING_TYPE_ID = 0;
+  static final int DATE_TYPE_ID = 1;
+  static final int TIMESTAMP_TYPE_ID = 2;
+  static final int BOOLEAN_TYPE_ID = 3;
+  static final int SHORT_TYPE_ID = 4;
+  static final int INT_TYPE_ID = 5;
+  static final int FLOAT_TYPE_ID = 6;
+  static final int LONG_TYPE_ID = 7;
+  static final int DOUBLE_TYPE_ID = 8;
+  static final int NULL_TYPE_ID = 9;
+  static final int BYTE_TYPE_ID = 10;
+  static final int BYTE_ARRAY_TYPE_ID = 11;
+  static final int SHORT_INT_TYPE_ID = 12;
+  static final int LEGACY_LONG_TYPE_ID = 13;
+  static final int DECIMAL_TYPE_ID = 20;
+  static final int ARRAY_TYPE_ID = 21;
+  static final int STRUCT_TYPE_ID = 22;
+  static final int MAP_TYPE_ID = 23;
+
+  /**
+   * create a DataType instance from uniqueId of the DataType
+   */
+  public static DataType valueOf(int id) {
+    if (id == STRING.getId()) {
+      return STRING;
+    } else if (id == DATE.getId()) {
+      return DATE;
+    } else if (id == TIMESTAMP.getId()) {
+      return TIMESTAMP;
+    } else if (id == BOOLEAN.getId()) {
+      return BOOLEAN;
+    } else if (id == BYTE.getId()) {
+      return BYTE;
+    } else if (id == SHORT.getId()) {
+      return SHORT;
+    } else if (id == SHORT_INT.getId()) {
+      return SHORT_INT;
+    } else if (id == INT.getId()) {
+      return INT;
+    } else if (id == LONG.getId()) {
+      return LONG;
+    } else if (id == LEGACY_LONG.getId()) {
+      return LEGACY_LONG;
+    } else if (id == FLOAT.getId()) {
+      return FLOAT;
+    } else if (id == DOUBLE.getId()) {
+      return DOUBLE;
+    } else if (id == NULL.getId()) {
+      return NULL;
+    } else if (id == DECIMAL.getId()) {
+      return DECIMAL;
+    } else if (id == ARRAY.getId()) {
+      return ARRAY;
+    } else if (id == STRUCT.getId()) {
+      return STRUCT;
+    } else if (id == MAP.getId()) {
+      return MAP;
+    } else if (id == BYTE_ARRAY.getId()) {
+      return BYTE_ARRAY;
+    } else {
+      throw new RuntimeException("create DataType with invalid id: " + id);
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DateType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DateType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DateType.java
new file mode 100644
index 0000000..2b930c3
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DateType.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.carbondata.core.metadata.datatype;
+
+public class DateType extends DataType {
+
+  public static final DataType DATE = new DateType(DataTypes.DATE_TYPE_ID, 1, "DATE", -1);
+
+  private DateType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.DATE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DecimalType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DecimalType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DecimalType.java
new file mode 100644
index 0000000..0c78e50
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DecimalType.java
@@ -0,0 +1,33 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class DecimalType extends DataType {
+
+  public static final DataType DECIMAL =
+      new DecimalType(DataTypes.DECIMAL_TYPE_ID, 8, "DECIMAL", -1);
+
+  private DecimalType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.DECIMAL;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DoubleType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DoubleType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DoubleType.java
new file mode 100644
index 0000000..59a4cc2
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/DoubleType.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.carbondata.core.metadata.datatype;
+
+public class DoubleType extends DataType {
+
+  public static final DataType DOUBLE = new DoubleType(DataTypes.DOUBLE_TYPE_ID, 6, "DOUBLE", 8);
+
+  private DoubleType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.DOUBLE;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/FloatType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/FloatType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/FloatType.java
new file mode 100644
index 0000000..1c0bfb6
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/FloatType.java
@@ -0,0 +1,31 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class FloatType extends DataType {
+  public static final DataType FLOAT = new FloatType(DataTypes.FLOAT_TYPE_ID, 4, "FLOAT", 4);
+
+  private FloatType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.FLOAT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/IntType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/IntType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/IntType.java
new file mode 100644
index 0000000..4324d9e
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/IntType.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.carbondata.core.metadata.datatype;
+
+public class IntType extends DataType {
+
+  public static final DataType INT = new IntType(DataTypes.INT_TYPE_ID, 3, "INT", 4);
+
+  private IntType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.INT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/LegacyLongType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/LegacyLongType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/LegacyLongType.java
new file mode 100644
index 0000000..610f2cc
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/LegacyLongType.java
@@ -0,0 +1,33 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+class LegacyLongType extends DataType {
+
+  static final DataType LEGACY_LONG =
+      new LegacyLongType(DataTypes.LEGACY_LONG_TYPE_ID, 15, "LEGACYBIGINT", 8);
+
+  private LegacyLongType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.LEGACY_LONG;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/LongType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/LongType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/LongType.java
new file mode 100644
index 0000000..3d05fd9
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/LongType.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.carbondata.core.metadata.datatype;
+
+public class LongType extends DataType {
+
+  public static final DataType LONG = new LongType(DataTypes.LONG_TYPE_ID, 5, "LONG", 8);
+
+  private LongType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.LONG;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/MapType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/MapType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/MapType.java
new file mode 100644
index 0000000..a360243
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/MapType.java
@@ -0,0 +1,37 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class MapType extends DataType {
+
+  public static final DataType MAP = new MapType(DataTypes.MAP_TYPE_ID, 11, "MAP", -1);
+
+  private MapType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.MAP;
+  }
+
+  @Override
+  public boolean isComplexType() {
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/NullType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/NullType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/NullType.java
new file mode 100644
index 0000000..43ffe41
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/NullType.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.carbondata.core.metadata.datatype;
+
+public class NullType extends DataType {
+
+  public static final DataType NULL = new NullType(DataTypes.NULL_TYPE_ID, 7, "NULL", 1);
+
+  private NullType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.NULL;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ShortIntType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ShortIntType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ShortIntType.java
new file mode 100644
index 0000000..5d57748
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ShortIntType.java
@@ -0,0 +1,38 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class ShortIntType extends DataType {
+
+  public static final DataType SHORT_INT =
+      new ShortIntType(DataTypes.SHORT_INT_TYPE_ID, 14, "SHORT_INT", 3);
+
+  private ShortIntType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  @Override
+  public int getSizeBits() {
+    throw new UnsupportedOperationException("Should not call this from SHORT_INT type");
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.SHORT_INT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ShortType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ShortType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ShortType.java
new file mode 100644
index 0000000..0085227
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/ShortType.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.carbondata.core.metadata.datatype;
+
+public class ShortType extends DataType {
+
+  public static final DataType SHORT = new ShortType(DataTypes.SHORT_TYPE_ID, 2, "SHORT", 2);
+
+  private ShortType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.SHORT;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/StringType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/StringType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/StringType.java
new file mode 100644
index 0000000..5c95480
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/StringType.java
@@ -0,0 +1,31 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class StringType extends DataType {
+  public static final DataType STRING = new StringType(DataTypes.STRING_TYPE_ID, 0, "STRING", -1);
+
+  private StringType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.STRING;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/StructType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/StructType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/StructType.java
new file mode 100644
index 0000000..081f952
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/StructType.java
@@ -0,0 +1,37 @@
+/*
+ * 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.carbondata.core.metadata.datatype;
+
+public class StructType extends DataType {
+
+  public static final DataType STRUCT = new StructType(DataTypes.STRUCT_TYPE_ID, 10, "STRUCT", -1);
+
+  private StructType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return DataTypes.STRUCT;
+  }
+
+  @Override
+  public boolean isComplexType() {
+    return true;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/datatype/TimestampType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/datatype/TimestampType.java b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/TimestampType.java
new file mode 100644
index 0000000..287c457
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/datatype/TimestampType.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.carbondata.core.metadata.datatype;
+
+public class TimestampType extends DataType {
+  public static final TimestampType TIMESTAMP =
+      new TimestampType(DataTypes.TIMESTAMP_TYPE_ID, 2, "TIMESTAMP", -1);
+
+  private TimestampType(int id, int precedenceOrder, String name, int sizeInBytes) {
+    super(id, precedenceOrder, name, sizeInBytes);
+  }
+
+  // this function is needed to ensure singleton pattern while supporting java serialization
+  private Object readResolve() {
+    return TIMESTAMP;
+  }
+}

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java
index 20f3224..a6738a3 100644
--- a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java
@@ -124,8 +124,6 @@ public class CarbonTable implements Serializable {
    */
   private int numberOfNoDictSortColumns;
 
-  private int lastDimensionColumnOrdinal;
-
   private CarbonTable() {
     this.tableDimensionsMap = new HashMap<String, List<CarbonDimension>>();
     this.tableImplicitDimensionsMap = new HashMap<String, List<CarbonDimension>>();
@@ -258,7 +256,6 @@ public class CarbonTable implements Serializable {
                  columnSchema.getSchemaOrdinal()));
       }
     }
-    lastDimensionColumnOrdinal = dimensionOrdinal;
     fillVisibleDimensions(tableSchema.getTableName());
     fillVisibleMeasures(tableSchema.getTableName());
     addImplicitDimension(dimensionOrdinal, implicitDimensions);

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonColumn.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonColumn.java b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonColumn.java
index 7cca993..13e7d49 100644
--- a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonColumn.java
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonColumn.java
@@ -128,7 +128,7 @@ public class CarbonColumn implements Serializable {
    * false.
    */
   public Boolean isComplex() {
-    return columnSchema.isComplex();
+    return columnSchema.getDataType().isComplexType();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonImplicitDimension.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonImplicitDimension.java b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonImplicitDimension.java
index 0fb3860..9e0cc22 100644
--- a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonImplicitDimension.java
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/CarbonImplicitDimension.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 
 /**
@@ -114,7 +115,7 @@ public class CarbonImplicitDimension extends CarbonDimension {
    * @return the dataType
    */
   @Override public DataType getDataType() {
-    return DataType.STRING;
+    return DataTypes.STRING;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/ColumnSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/ColumnSchema.java b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/ColumnSchema.java
index 3680d53..bd246a4 100644
--- a/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/ColumnSchema.java
+++ b/core/src/main/java/org/apache/carbondata/core/metadata/schema/table/column/ColumnSchema.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.Writable;
 import org.apache.carbondata.core.metadata.schema.table.WritableUtil;
@@ -349,18 +350,6 @@ public class ColumnSchema implements Serializable, Writable {
   }
 
   /**
-   * @return if DataType is ARRAY or STRUCT, this method return true, else
-   * false.
-   */
-  public Boolean isComplex() {
-    if (DataType.ARRAY.equals(this.getDataType()) || DataType.STRUCT.equals(this.getDataType())) {
-      return true;
-    } else {
-      return false;
-    }
-  }
-
-  /**
    * @param columnProperties
    */
   public void setColumnProperties(Map<String, String> columnProperties) {
@@ -421,7 +410,7 @@ public class ColumnSchema implements Serializable, Writable {
 
   @Override
   public void write(DataOutput out) throws IOException {
-    out.writeShort(dataType.ordinal());
+    out.writeShort(dataType.getId());
     out.writeUTF(columnName);
     out.writeUTF(columnUniqueId);
     out.writeUTF(columnReferenceId);
@@ -454,16 +443,16 @@ public class ColumnSchema implements Serializable, Writable {
 
   @Override
   public void readFields(DataInput in) throws IOException {
-    int ordinal = in.readShort();
-    this.dataType = DataType.valueOf(ordinal);
+    int id = in.readShort();
+    this.dataType = DataTypes.valueOf(id);
     this.columnName = in.readUTF();
     this.columnUniqueId = in.readUTF();
     this.columnReferenceId = in.readUTF();
     int encodingListSize = in.readShort();
     this.encodingList = new ArrayList<>(encodingListSize);
     for (int i = 0; i < encodingListSize; i++) {
-      ordinal = in.readShort();
-      encodingList.add(Encoding.valueOf(ordinal));
+      id = in.readShort();
+      encodingList.add(Encoding.valueOf(id));
     }
     this.isDimensionColumn = in.readBoolean();
     this.scale = in.readInt();

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/AbstractScannedResultCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/AbstractScannedResultCollector.java b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/AbstractScannedResultCollector.java
index 84995b9..1fa42dc 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/AbstractScannedResultCollector.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/AbstractScannedResultCollector.java
@@ -23,6 +23,7 @@ import org.apache.carbondata.common.logging.LogService;
 import org.apache.carbondata.common.logging.LogServiceFactory;
 import org.apache.carbondata.core.datastore.page.ColumnPage;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
 import org.apache.carbondata.core.scan.collector.ScannedResultCollector;
 import org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo;
@@ -77,7 +78,7 @@ public abstract class AbstractScannedResultCollector implements ScannedResultCol
       } else {
         // if not then get the default value and use that value in aggregation
         Object defaultValue = measureInfo.getDefaultValues()[i];
-        if (null != defaultValue && measureInfo.getMeasureDataTypes()[i] == DataType.DECIMAL) {
+        if (null != defaultValue && measureInfo.getMeasureDataTypes()[i] == DataTypes.DECIMAL) {
           // convert data type as per the computing engine
           defaultValue = DataTypeUtil.getDataTypeConverter().convertToDecimal(defaultValue);
         }
@@ -89,24 +90,23 @@ public abstract class AbstractScannedResultCollector implements ScannedResultCol
   protected Object getMeasureData(ColumnPage dataChunk, int index,
       CarbonMeasure carbonMeasure) {
     if (!dataChunk.getNullBits().get(index)) {
-      switch (carbonMeasure.getDataType()) {
-        case SHORT:
-          return (short)dataChunk.getLong(index);
-        case INT:
-          return (int)dataChunk.getLong(index);
-        case LONG:
-          return dataChunk.getLong(index);
-        case DECIMAL:
-          BigDecimal bigDecimalMsrValue =
-              dataChunk.getDecimal(index);
-          if (null != bigDecimalMsrValue && carbonMeasure.getScale() > bigDecimalMsrValue.scale()) {
-            bigDecimalMsrValue =
-                bigDecimalMsrValue.setScale(carbonMeasure.getScale(), RoundingMode.HALF_UP);
-          }
-          // convert data type as per the computing engine
-          return DataTypeUtil.getDataTypeConverter().convertToDecimal(bigDecimalMsrValue);
-        default:
-          return dataChunk.getDouble(index);
+      DataType dataType = carbonMeasure.getDataType();
+      if (dataType == DataTypes.SHORT) {
+        return (short) dataChunk.getLong(index);
+      } else if (dataType == DataTypes.INT) {
+        return (int) dataChunk.getLong(index);
+      } else if (dataType == DataTypes.LONG) {
+        return dataChunk.getLong(index);
+      } else if (dataType == DataTypes.DECIMAL) {
+        BigDecimal bigDecimalMsrValue = dataChunk.getDecimal(index);
+        if (null != bigDecimalMsrValue && carbonMeasure.getScale() > bigDecimalMsrValue.scale()) {
+          bigDecimalMsrValue =
+              bigDecimalMsrValue.setScale(carbonMeasure.getScale(), RoundingMode.HALF_UP);
+        }
+        // convert data type as per the computing engine
+        return DataTypeUtil.getDataTypeConverter().convertToDecimal(bigDecimalMsrValue);
+      } else {
+        return dataChunk.getDouble(index);
       }
     }
     return null;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
index 5522ff2..cf6e6d6 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
@@ -25,7 +25,7 @@ import java.util.Map;
 import org.apache.carbondata.core.constants.CarbonCommonConstants;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo;
 import org.apache.carbondata.core.scan.filter.GenericQueryType;
@@ -128,10 +128,10 @@ public class DictionaryBasedResultCollector extends AbstractScannedResultCollect
           row[order[i]] = DataTypeUtil.getDataBasedOnDataType(
               scannedResult.getBlockletId() + CarbonCommonConstants.FILE_SEPARATOR + scannedResult
                   .getCurrentPageCounter() + CarbonCommonConstants.FILE_SEPARATOR + scannedResult
-                  .getCurrentRowId(), DataType.STRING);
+                  .getCurrentRowId(), DataTypes.STRING);
         } else {
           row[order[i]] =
-              DataTypeUtil.getDataBasedOnDataType(scannedResult.getBlockletId(), DataType.STRING);
+              DataTypeUtil.getDataBasedOnDataType(scannedResult.getBlockletId(), DataTypes.STRING);
         }
       } else {
         row[order[i]] = DataTypeUtil.getDataBasedOnDataTypeForNoDictionaryColumn(

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedRawResultCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedRawResultCollector.java b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedRawResultCollector.java
index 45275a5..b08a1d4 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedRawResultCollector.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedRawResultCollector.java
@@ -26,7 +26,7 @@ import org.apache.carbondata.core.datastore.block.SegmentProperties;
 import org.apache.carbondata.core.keygenerator.KeyGenException;
 import org.apache.carbondata.core.keygenerator.KeyGenerator;
 import org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator;
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo;
@@ -239,7 +239,7 @@ public class RestructureBasedRawResultCollector extends RawBasedResultCollector
           Object defaultValue = dimensionInfo.getDefaultValues()[i];
           if (null != defaultValue) {
             newColumnDefaultValue = ((UTF8String) defaultValue).getBytes();
-          } else if (actualQueryDimensions[i].getDimension().getDataType() == DataType.STRING) {
+          } else if (actualQueryDimensions[i].getDimension().getDataType() == DataTypes.STRING) {
             newColumnDefaultValue =
                 UTF8String.fromString(CarbonCommonConstants.MEMBER_DEFAULT_VAL).getBytes();
           } else {

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedVectorResultCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedVectorResultCollector.java b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedVectorResultCollector.java
index 65b9a17..cbde2e1 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedVectorResultCollector.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedVectorResultCollector.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
@@ -60,8 +61,8 @@ public class RestructureBasedVectorResultCollector extends DictionaryBasedVector
         // add a dummy column vector result collector object
         ColumnVectorInfo columnVectorInfo = new ColumnVectorInfo();
         columnVectorInfo.dimension = queryDimensions[i];
-        if (queryDimensions[i].getDimension().getDataType().equals(DataType.TIMESTAMP)
-            || queryDimensions[i].getDimension().getDataType().equals(DataType.DATE)) {
+        if (queryDimensions[i].getDimension().getDataType().equals(DataTypes.TIMESTAMP)
+            || queryDimensions[i].getDimension().getDataType().equals(DataTypes.DATE)) {
           columnVectorInfo.directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory
               .getDirectDictionaryGenerator(queryDimensions[i].getDimension().getDataType());
         }
@@ -177,7 +178,7 @@ public class RestructureBasedVectorResultCollector extends DictionaryBasedVector
   private void fillDirectDictionaryData(CarbonColumnVector vector,
       ColumnVectorInfo columnVectorInfo, Object defaultValue) {
     if (null != defaultValue) {
-      if (columnVectorInfo.directDictionaryGenerator.getReturnType().equals(DataType.INT)) {
+      if (columnVectorInfo.directDictionaryGenerator.getReturnType().equals(DataTypes.INT)) {
         vector.putInts(columnVectorInfo.vectorOffset, columnVectorInfo.size, (int) defaultValue);
       } else {
         vector.putLongs(columnVectorInfo.vectorOffset, columnVectorInfo.size, (long) defaultValue);
@@ -197,18 +198,14 @@ public class RestructureBasedVectorResultCollector extends DictionaryBasedVector
   private void fillNoDictionaryData(CarbonColumnVector vector, ColumnVectorInfo columnVectorInfo,
       Object defaultValue) {
     if (null != defaultValue) {
-      switch (columnVectorInfo.dimension.getDimension().getDataType()) {
-        case INT:
-          vector.putInts(columnVectorInfo.vectorOffset, columnVectorInfo.size, (int) defaultValue);
-          break;
-        case LONG:
-        case TIMESTAMP:
-          vector
-              .putLongs(columnVectorInfo.vectorOffset, columnVectorInfo.size, (long) defaultValue);
-          break;
-        default:
-          vector.putBytes(columnVectorInfo.vectorOffset, columnVectorInfo.size,
-              ((UTF8String) defaultValue).getBytes());
+      DataType dataType = columnVectorInfo.dimension.getDimension().getDataType();
+      if (dataType == DataTypes.INT) {
+        vector.putInts(columnVectorInfo.vectorOffset, columnVectorInfo.size, (int) defaultValue);
+      } else if (dataType == DataTypes.LONG || dataType == DataTypes.TIMESTAMP) {
+        vector.putLongs(columnVectorInfo.vectorOffset, columnVectorInfo.size, (long) defaultValue);
+      } else {
+        vector.putBytes(columnVectorInfo.vectorOffset, columnVectorInfo.size,
+            ((UTF8String) defaultValue).getBytes());
       }
     } else {
       vector.putNulls(columnVectorInfo.vectorOffset, columnVectorInfo.size);
@@ -229,26 +226,22 @@ public class RestructureBasedVectorResultCollector extends DictionaryBasedVector
         if (null == defaultValue) {
           vector.putNulls(columnVectorInfo.vectorOffset, columnVectorInfo.size);
         } else {
-          switch (measureInfo.getMeasureDataTypes()[i]) {
-            case SHORT:
-              vector.putShorts(columnVectorInfo.vectorOffset, columnVectorInfo.size,
-                  (short) defaultValue);
-              break;
-            case INT:
-              vector.putInts(columnVectorInfo.vectorOffset, columnVectorInfo.size,
-                  (int) defaultValue);
-              break;
-            case LONG:
-              vector.putLongs(columnVectorInfo.vectorOffset, columnVectorInfo.size,
-                  (long) defaultValue);
-              break;
-            case DECIMAL:
-              vector.putDecimals(columnVectorInfo.vectorOffset, columnVectorInfo.size,
-                  (Decimal) defaultValue, measure.getPrecision());
-              break;
-            default:
-              vector.putDoubles(columnVectorInfo.vectorOffset, columnVectorInfo.size,
-                  (double) defaultValue);
+          DataType dataType = measureInfo.getMeasureDataTypes()[i];
+          if (dataType == DataTypes.SHORT) {
+            vector.putShorts(columnVectorInfo.vectorOffset, columnVectorInfo.size,
+                (short) defaultValue);
+          } else if (dataType == DataTypes.INT) {
+            vector
+                .putInts(columnVectorInfo.vectorOffset, columnVectorInfo.size, (int) defaultValue);
+          } else if (dataType == DataTypes.LONG) {
+            vector.putLongs(columnVectorInfo.vectorOffset, columnVectorInfo.size,
+                (long) defaultValue);
+          } else if (dataType == DataTypes.DECIMAL) {
+            vector.putDecimals(columnVectorInfo.vectorOffset, columnVectorInfo.size,
+                (Decimal) defaultValue, measure.getPrecision());
+          } else {
+            vector.putDoubles(columnVectorInfo.vectorOffset, columnVectorInfo.size,
+                (double) defaultValue);
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/complextypes/ArrayQueryType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/complextypes/ArrayQueryType.java b/core/src/main/java/org/apache/carbondata/core/scan/complextypes/ArrayQueryType.java
index 39227a3..1fcccca 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/complextypes/ArrayQueryType.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/complextypes/ArrayQueryType.java
@@ -25,8 +25,9 @@ import org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk;
 import org.apache.carbondata.core.scan.filter.GenericQueryType;
 import org.apache.carbondata.core.scan.processor.BlocksChunkHolder;
 
-import org.apache.spark.sql.catalyst.util.*;
-import org.apache.spark.sql.types.*;
+import org.apache.spark.sql.catalyst.util.GenericArrayData;
+import org.apache.spark.sql.types.ArrayType;
+import org.apache.spark.sql.types.DataType;
 
 public class ArrayQueryType extends ComplexQueryType implements GenericQueryType {
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/complextypes/PrimitiveQueryType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/complextypes/PrimitiveQueryType.java b/core/src/main/java/org/apache/carbondata/core/scan/complextypes/PrimitiveQueryType.java
index 56c265b..978a652 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/complextypes/PrimitiveQueryType.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/complextypes/PrimitiveQueryType.java
@@ -96,21 +96,20 @@ public class PrimitiveQueryType extends ComplexQueryType implements GenericQuery
   }
 
   @Override public DataType getSchemaType() {
-    switch (dataType) {
-      case INT:
-        return IntegerType$.MODULE$;
-      case DOUBLE:
-        return DoubleType$.MODULE$;
-      case LONG:
-        return LongType$.MODULE$;
-      case BOOLEAN:
-        return BooleanType$.MODULE$;
-      case TIMESTAMP:
-        return TimestampType$.MODULE$;
-      case DATE:
-        return DateType$.MODULE$;
-      default:
-        return IntegerType$.MODULE$;
+    if (dataType == org.apache.carbondata.core.metadata.datatype.DataTypes.INT) {
+      return IntegerType$.MODULE$;
+    } else if (dataType == org.apache.carbondata.core.metadata.datatype.DataTypes.DOUBLE) {
+      return DoubleType$.MODULE$;
+    } else if (dataType == org.apache.carbondata.core.metadata.datatype.DataTypes.LONG) {
+      return LongType$.MODULE$;
+    } else if (dataType == org.apache.carbondata.core.metadata.datatype.DataTypes.BOOLEAN) {
+      return BooleanType$.MODULE$;
+    } else if (dataType == org.apache.carbondata.core.metadata.datatype.DataTypes.TIMESTAMP) {
+      return TimestampType$.MODULE$;
+    } else if (dataType == org.apache.carbondata.core.metadata.datatype.DataTypes.DATE) {
+      return DateType$.MODULE$;
+    } else {
+      return IntegerType$.MODULE$;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java b/core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
index 25c827b..b2c1a2b 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/executor/impl/AbstractQueryExecutor.java
@@ -49,6 +49,7 @@ import org.apache.carbondata.core.keygenerator.KeyGenerator;
 import org.apache.carbondata.core.memory.UnsafeMemoryManager;
 import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.CarbonTable;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
@@ -478,7 +479,7 @@ public abstract class AbstractQueryExecutor<E> implements QueryExecutor<E> {
     List<Integer> parentBlockIndexList = new ArrayList<Integer>();
     for (QueryDimension queryDimension : queryDimensions) {
       if (CarbonUtil.hasDataType(queryDimension.getDimension().getDataType(),
-          new DataType[] { DataType.ARRAY, DataType.STRUCT, DataType.MAP })) {
+          new DataType[] { DataTypes.ARRAY, DataTypes.STRUCT, DataTypes.MAP })) {
         parentBlockIndexList.add(queryDimension.getDimension().getOrdinal());
       }
     }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/executor/util/QueryUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/executor/util/QueryUtil.java b/core/src/main/java/org/apache/carbondata/core/scan/executor/util/QueryUtil.java
index ee09793..59387b3 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/executor/util/QueryUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/executor/util/QueryUtil.java
@@ -43,6 +43,7 @@ import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
 import org.apache.carbondata.core.metadata.CarbonMetadata;
 import org.apache.carbondata.core.metadata.CarbonTableIdentifier;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.CarbonTable;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
@@ -778,10 +779,18 @@ public class QueryUtil {
       CarbonDimension dimension, Map<Integer, GenericQueryType> complexTypeMap,
       int[] eachComplexColumnValueSize, Map<String, Dictionary> columnIdToDictionaryMap) {
     int parentBlockIndex = dimensionToBlockIndexMap.get(dimension.getOrdinal());
-    GenericQueryType parentQueryType = dimension.getDataType().equals(DataType.ARRAY) ?
-        new ArrayQueryType(dimension.getColName(), dimension.getColName(), parentBlockIndex) :
-        new StructQueryType(dimension.getColName(), dimension.getColName(),
-            dimensionToBlockIndexMap.get(dimension.getOrdinal()));
+    GenericQueryType parentQueryType;
+    if (dimension.getDataType() == DataTypes.ARRAY) {
+      parentQueryType =
+          new ArrayQueryType(dimension.getColName(), dimension.getColName(), parentBlockIndex);
+    } else if (dimension.getDataType() == DataTypes.STRUCT) {
+      parentQueryType =
+          new StructQueryType(dimension.getColName(), dimension.getColName(),
+              dimensionToBlockIndexMap.get(dimension.getOrdinal()));
+    } else {
+      throw new UnsupportedOperationException(dimension.getDataType().getName() +
+          " is not supported");
+    }
     complexTypeMap.put(dimension.getOrdinal(), parentQueryType);
     fillChildrenDetails(eachComplexColumnValueSize, columnIdToDictionaryMap, parentBlockIndex,
             dimension, parentQueryType);
@@ -791,29 +800,27 @@ public class QueryUtil {
       Map<String, Dictionary> columnIdToDictionaryMap, int parentBlockIndex,
       CarbonDimension dimension, GenericQueryType parentQueryType) {
     for (int i = 0; i < dimension.getNumberOfChild(); i++) {
-      switch (dimension.getListOfChildDimensions().get(i).getDataType()) {
-        case ARRAY:
-          parentQueryType.addChildren(
-              new ArrayQueryType(dimension.getListOfChildDimensions().get(i).getColName(),
-                  dimension.getColName(), ++parentBlockIndex));
-          break;
-        case STRUCT:
-          parentQueryType.addChildren(
-              new StructQueryType(dimension.getListOfChildDimensions().get(i).getColName(),
-                  dimension.getColName(), ++parentBlockIndex));
-          break;
-        default:
-          boolean isDirectDictionary = CarbonUtil
-              .hasEncoding(dimension.getListOfChildDimensions().get(i).getEncoder(),
-                  Encoding.DIRECT_DICTIONARY);
-          parentQueryType.addChildren(
-              new PrimitiveQueryType(dimension.getListOfChildDimensions().get(i).getColName(),
-                  dimension.getColName(), ++parentBlockIndex,
-                  dimension.getListOfChildDimensions().get(i).getDataType(),
-                  eachComplexColumnValueSize[dimension.getListOfChildDimensions().get(i)
-                      .getComplexTypeOrdinal()], columnIdToDictionaryMap
-                  .get(dimension.getListOfChildDimensions().get(i).getColumnId()),
-                  isDirectDictionary));
+      DataType dataType = dimension.getListOfChildDimensions().get(i).getDataType();
+      if (dataType == DataTypes.ARRAY) {
+        parentQueryType.addChildren(
+            new ArrayQueryType(dimension.getListOfChildDimensions().get(i).getColName(),
+                dimension.getColName(), ++parentBlockIndex));
+      } else if (dataType == DataTypes.STRUCT) {
+        parentQueryType.addChildren(
+            new StructQueryType(dimension.getListOfChildDimensions().get(i).getColName(),
+                dimension.getColName(), ++parentBlockIndex));
+      } else {
+        boolean isDirectDictionary = CarbonUtil
+            .hasEncoding(dimension.getListOfChildDimensions().get(i).getEncoder(),
+                Encoding.DIRECT_DICTIONARY);
+        parentQueryType.addChildren(
+            new PrimitiveQueryType(dimension.getListOfChildDimensions().get(i).getColName(),
+                dimension.getColName(), ++parentBlockIndex,
+                dimension.getListOfChildDimensions().get(i).getDataType(),
+                eachComplexColumnValueSize[dimension.getListOfChildDimensions().get(i)
+                    .getComplexTypeOrdinal()], columnIdToDictionaryMap
+                .get(dimension.getListOfChildDimensions().get(i).getColumnId()),
+                isDirectDictionary));
       }
       if (dimension.getListOfChildDimensions().get(i).getNumberOfChild() > 0) {
         parentBlockIndex = fillChildrenDetails(eachComplexColumnValueSize, columnIdToDictionaryMap,


Mime
View raw message