carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject [10/35] carbondata git commit: [CARBONDATA-1539] Change data type from enum to class
Date Mon, 30 Oct 2017 09:22:00 GMT
http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/executor/util/RestructureUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/executor/util/RestructureUtil.java b/core/src/main/java/org/apache/carbondata/core/scan/executor/util/RestructureUtil.java
index 6a281dd..ddc75ff 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/executor/util/RestructureUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/executor/util/RestructureUtil.java
@@ -26,6 +26,7 @@ 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.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
@@ -217,21 +218,17 @@ public class RestructureUtil {
     Object noDictionaryDefaultValue = null;
     String value = null;
     if (!isDefaultValueNull(defaultValue)) {
-      switch (datatype) {
-        case INT:
-          value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          noDictionaryDefaultValue = Integer.parseInt(value);
-          break;
-        case LONG:
-          value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          noDictionaryDefaultValue = Long.parseLong(value);
-          break;
-        case TIMESTAMP:
-          long timestampValue = ByteUtil.toLong(defaultValue, 0, defaultValue.length);
-          noDictionaryDefaultValue = timestampValue * 1000L;
-          break;
-        default:
-          noDictionaryDefaultValue = UTF8String.fromBytes(defaultValue);
+      if (datatype == DataTypes.INT) {
+        value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+        noDictionaryDefaultValue = Integer.parseInt(value);
+      } else if (datatype == DataTypes.LONG) {
+        value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+        noDictionaryDefaultValue = Long.parseLong(value);
+      } else if (datatype == DataTypes.TIMESTAMP) {
+        long timestampValue = ByteUtil.toLong(defaultValue, 0, defaultValue.length);
+        noDictionaryDefaultValue = timestampValue * 1000L;
+      } else {
+        noDictionaryDefaultValue = UTF8String.fromBytes(defaultValue);
       }
     }
     return noDictionaryDefaultValue;
@@ -244,10 +241,7 @@ public class RestructureUtil {
    * @return
    */
   private static boolean isDefaultValueNull(byte[] defaultValue) {
-    if (null == defaultValue) {
-      return true;
-    }
-    return false;
+    return null == defaultValue;
   }
 
   /**
@@ -294,28 +288,22 @@ public class RestructureUtil {
     Object measureDefaultValue = null;
     if (!isDefaultValueNull(defaultValue)) {
       String value = null;
-      switch (columnSchema.getDataType()) {
-        case SHORT:
-        case INT:
-        case LONG:
-          value =
-              new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          measureDefaultValue = Long.parseLong(value);
-          break;
-        case DECIMAL:
-          BigDecimal decimal = DataTypeUtil.byteToBigDecimal(defaultValue);
-          if (columnSchema.getScale() > decimal.scale()) {
-            decimal = decimal.setScale(columnSchema.getScale(), RoundingMode.HALF_UP);
-          }
-          measureDefaultValue = decimal;
-          break;
-        default:
-          value =
-              new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          Double parsedValue = Double.valueOf(value);
-          if (!Double.isInfinite(parsedValue) && !Double.isNaN(parsedValue)) {
-            measureDefaultValue = parsedValue;
-          }
+      DataType dataType = columnSchema.getDataType();
+      if (dataType == DataTypes.SHORT || dataType == DataTypes.INT || dataType == DataTypes.LONG) {
+        value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+        measureDefaultValue = Long.parseLong(value);
+      } else if (dataType == DataTypes.DECIMAL) {
+        BigDecimal decimal = DataTypeUtil.byteToBigDecimal(defaultValue);
+        if (columnSchema.getScale() > decimal.scale()) {
+          decimal = decimal.setScale(columnSchema.getScale(), RoundingMode.HALF_UP);
+        }
+        measureDefaultValue = decimal;
+      } else {
+        value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+        Double parsedValue = Double.valueOf(value);
+        if (!Double.isInfinite(parsedValue) && !Double.isNaN(parsedValue)) {
+          measureDefaultValue = parsedValue;
+        }
       }
     }
     return measureDefaultValue;
@@ -333,36 +321,28 @@ public class RestructureUtil {
     Object measureDefaultValue = null;
     if (!isDefaultValueNull(defaultValue)) {
       String value = null;
-      switch (columnSchema.getDataType()) {
-        case SHORT:
-          value =
-              new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          measureDefaultValue = Short.parseShort(value);
-          break;
-        case INT:
-          value =
-              new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          measureDefaultValue = Integer.parseInt(value);
-          break;
-        case LONG:
-          value =
-              new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          measureDefaultValue = Long.parseLong(value);
-          break;
-        case DECIMAL:
-          BigDecimal decimal = DataTypeUtil.byteToBigDecimal(defaultValue);
-          if (columnSchema.getScale() > decimal.scale()) {
-            decimal = decimal.setScale(columnSchema.getScale(), RoundingMode.HALF_UP);
-          }
-          measureDefaultValue = Decimal.apply(decimal);
-          break;
-        default:
-          value =
-              new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          Double parsedValue = Double.valueOf(value);
-          if (!Double.isInfinite(parsedValue) && !Double.isNaN(parsedValue)) {
-            measureDefaultValue = parsedValue;
-          }
+      DataType dataType = columnSchema.getDataType();
+      if (dataType == DataTypes.SHORT) {
+        value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+        measureDefaultValue = Short.parseShort(value);
+      } else if (dataType == DataTypes.INT) {
+        value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+        measureDefaultValue = Integer.parseInt(value);
+      } else if (dataType == DataTypes.LONG) {
+        value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+        measureDefaultValue = Long.parseLong(value);
+      } else if (dataType == DataTypes.DECIMAL) {
+        BigDecimal decimal = DataTypeUtil.byteToBigDecimal(defaultValue);
+        if (columnSchema.getScale() > decimal.scale()) {
+          decimal = decimal.setScale(columnSchema.getScale(), RoundingMode.HALF_UP);
+        }
+        measureDefaultValue = Decimal.apply(decimal);
+      } else {
+        value = new String(defaultValue, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+        Double parsedValue = Double.valueOf(value);
+        if (!Double.isInfinite(parsedValue) && !Double.isNaN(parsedValue)) {
+          measureDefaultValue = parsedValue;
+        }
       }
     }
     return measureDefaultValue;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java
index 08b1972..e3892be 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/ExpressionResult.java
@@ -29,6 +29,7 @@ import java.util.TimeZone;
 import org.apache.carbondata.core.constants.CarbonCommonConstants;
 import org.apache.carbondata.core.keygenerator.directdictionary.timestamp.DateDirectDictionaryGenerator;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
 import org.apache.carbondata.core.util.CarbonUtil;
 
@@ -71,48 +72,48 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       return null;
     }
     try {
-      switch (this.getDataType()) {
-        case STRING:
-          try {
-            return Integer.parseInt(value.toString());
-          } catch (NumberFormatException e) {
-            throw new FilterIllegalMemberException(e);
-          }
-        case SHORT:
-          return ((Short) value).intValue();
-        case INT:
-        case DOUBLE:
-          if (value instanceof Double) {
-            return ((Double) value).intValue();
-          }
-          if (value instanceof Long) {
-            return ((Long) value).intValue();
-          }
+      DataType dataType = this.getDataType();
+      if (dataType == DataTypes.STRING) {
+        try {
+          return Integer.parseInt(value.toString());
+        } catch (NumberFormatException e) {
+          throw new FilterIllegalMemberException(e);
+        }
+      } else if (dataType == DataTypes.SHORT) {
+        return ((Short) value).intValue();
+      } else if (dataType == DataTypes.INT ||
+          dataType == DataTypes.DOUBLE) {
+        if (value instanceof Double) {
+          return ((Double) value).intValue();
+        }
+        if (value instanceof Long) {
+          return ((Long) value).intValue();
+        }
+        return (Integer) value;
+      } else if (dataType == DataTypes.DATE) {
+        if (value instanceof java.sql.Date) {
+          return (int) (((java.sql.Date) value).getTime());
+        } else {
           return (Integer) value;
-        case DATE:
-          if (value instanceof java.sql.Date) {
-            return (int) (((java.sql.Date) value).getTime());
-          } else {
-            return (Integer) value;
+        }
+      } else if (dataType == DataTypes.TIMESTAMP) {
+        if (value instanceof Timestamp) {
+          return (int) (((Timestamp) value).getTime());
+        } else {
+          if (isLiteral) {
+            Long l = (Long) value / 1000;
+            return l.intValue();
           }
-        case TIMESTAMP:
-          if (value instanceof Timestamp) {
-            return (int) (((Timestamp) value).getTime());
-          } else {
-            if (isLiteral) {
-              Long l = (Long) value / 1000;
-              return l.intValue();
-            }
-            return (Integer) value;
-          }
-        default:
-          throw new FilterIllegalMemberException(
-              "Cannot convert" + this.getDataType().name() + " to integer type value");
+          return (Integer) value;
+        }
+      } else {
+        throw new FilterIllegalMemberException(
+            "Cannot convert" + this.getDataType().getName() + " to integer type value");
       }
 
     } catch (ClassCastException e) {
       throw new FilterIllegalMemberException(
-          "Cannot convert" + this.getDataType().name() + " to Integer type value");
+          "Cannot convert" + this.getDataType().getName() + " to Integer type value");
     }
   }
 
@@ -121,51 +122,46 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       return null;
     }
     try {
-      switch (this.getDataType()) {
-        case STRING:
-          try {
-            return Short.parseShort(value.toString());
-          } catch (NumberFormatException e) {
-            throw new FilterIllegalMemberException(e);
-          }
-        case SHORT:
-        case INT:
-        case DOUBLE:
-
-          if (value instanceof Double) {
-            return ((Double) value).shortValue();
-          } else if (value instanceof Integer) {
-            return ((Integer) value).shortValue();
-          }
+      DataType dataType = this.getDataType();
+      if (dataType == DataTypes.STRING) {
+        try {
+          return Short.parseShort(value.toString());
+        } catch (NumberFormatException e) {
+          throw new FilterIllegalMemberException(e);
+        }
+      } else if (dataType == DataTypes.SHORT ||
+          dataType == DataTypes.INT ||
+          dataType == DataTypes.DOUBLE) {
+        if (value instanceof Double) {
+          return ((Double) value).shortValue();
+        } else if (value instanceof Integer) {
+          return ((Integer) value).shortValue();
+        }
+        return (Short) value;
+      } else if (dataType == DataTypes.DATE) {
+        if (value instanceof java.sql.Date) {
+          return (short) (((java.sql.Date) value).getTime());
+        } else {
           return (Short) value;
-
-        case DATE:
-
-          if (value instanceof java.sql.Date) {
-            return (short) (((java.sql.Date) value).getTime());
-          } else {
-            return (Short) value;
+        }
+      } else if (dataType == DataTypes.TIMESTAMP) {
+        if (value instanceof Timestamp) {
+          return (short) (((Timestamp) value).getTime());
+        } else {
+          if (isLiteral) {
+            Long l = ((long) value / 1000);
+            return l.shortValue();
           }
-        case TIMESTAMP:
-
-          if (value instanceof Timestamp) {
-            return (short) (((Timestamp) value).getTime());
-          } else {
-            if (isLiteral) {
-              Long l = ((long) value / 1000);
-              return l.shortValue();
-            }
-            return (Short) value;
-          }
-
-        default:
-          throw new FilterIllegalMemberException(
-              "Cannot convert" + this.getDataType().name() + " to integer type value");
+          return (Short) value;
+        }
+      } else {
+        throw new FilterIllegalMemberException(
+            "Cannot convert" + this.getDataType().getName() + " to integer type value");
       }
 
     } catch (ClassCastException e) {
       throw new FilterIllegalMemberException(
-          "Cannot convert" + this.getDataType().name() + " to Integer type value");
+          "Cannot convert" + this.getDataType().getName() + " to Integer type value");
     }
   }
 
@@ -174,34 +170,33 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       return null;
     }
     try {
-      switch (this.getDataType()) {
-        case DATE:
-        case TIMESTAMP:
-          String format = CarbonUtil.getFormatFromProperty(this.getDataType());
-          SimpleDateFormat parser = new SimpleDateFormat(format);
-          if (this.getDataType() == DataType.DATE) {
-            parser.setTimeZone(TimeZone.getTimeZone("GMT"));
-          }
-          if (value instanceof Timestamp) {
-            return parser.format((Timestamp) value);
-          } else if (value instanceof java.sql.Date) {
-            return parser.format((java.sql.Date) value);
-          } else if (value instanceof Long) {
-            if (isLiteral) {
-              return parser.format(new Timestamp((long) value / 1000));
-            }
-            return parser.format(new Timestamp((long) value));
-          } else if (value instanceof Integer) {
-            long date = ((int) value) * DateDirectDictionaryGenerator.MILLIS_PER_DAY;
-            return parser.format(new java.sql.Date(date));
+      DataType dataType = this.getDataType();
+      if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+        String format = CarbonUtil.getFormatFromProperty(this.getDataType());
+        SimpleDateFormat parser = new SimpleDateFormat(format);
+        if (this.getDataType() == DataTypes.DATE) {
+          parser.setTimeZone(TimeZone.getTimeZone("GMT"));
+        }
+        if (value instanceof Timestamp) {
+          return parser.format((Timestamp) value);
+        } else if (value instanceof java.sql.Date) {
+          return parser.format((java.sql.Date) value);
+        } else if (value instanceof Long) {
+          if (isLiteral) {
+            return parser.format(new Timestamp((long) value / 1000));
           }
-          return value.toString();
-        default:
-          return value.toString();
+          return parser.format(new Timestamp((long) value));
+        } else if (value instanceof Integer) {
+          long date = ((int) value) * DateDirectDictionaryGenerator.MILLIS_PER_DAY;
+          return parser.format(new java.sql.Date(date));
+        }
+        return value.toString();
+      } else {
+        return value.toString();
       }
     } catch (Exception e) {
       throw new FilterIllegalMemberException(
-          "Cannot convert" + this.getDataType().name() + " to String type value");
+          "Cannot convert" + this.getDataType().getName() + " to String type value");
     }
   }
 
@@ -210,44 +205,44 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       return null;
     }
     try {
-      switch (this.getDataType()) {
-        case STRING:
-          try {
-            return Double.parseDouble(value.toString());
-          } catch (NumberFormatException e) {
-            throw new FilterIllegalMemberException(e);
+      DataType dataType = this.getDataType();
+      if (dataType == DataTypes.STRING) {
+        try {
+          return Double.parseDouble(value.toString());
+        } catch (NumberFormatException e) {
+          throw new FilterIllegalMemberException(e);
+        }
+      } else if (dataType == DataTypes.SHORT) {
+        return ((Short) value).doubleValue();
+      } else if (dataType == DataTypes.INT) {
+        return ((Integer) value).doubleValue();
+      } else if (dataType == DataTypes.LONG) {
+        return ((Long) value).doubleValue();
+      } else if (dataType == DataTypes.DOUBLE) {
+        return (Double) value;
+      } else if (dataType == DataTypes.DATE) {
+        if (value instanceof java.sql.Date) {
+          return (double) ((java.sql.Date) value).getTime();
+        } else {
+          return (Double) (value);
+        }
+      } else if (dataType == DataTypes.TIMESTAMP) {
+        if (value instanceof Timestamp) {
+          return (double) ((Timestamp) value).getTime();
+        } else {
+          if (isLiteral) {
+            Long l = (Long) value / 1000;
+            return l.doubleValue();
           }
-        case SHORT:
-          return ((Short) value).doubleValue();
-        case INT:
-          return ((Integer) value).doubleValue();
-        case LONG:
-          return ((Long) value).doubleValue();
-        case DOUBLE:
-          return (Double) value;
-        case DATE:
-          if (value instanceof java.sql.Date) {
-            return (double) ((java.sql.Date) value).getTime();
-          } else {
-            return (Double) (value);
-          }
-        case TIMESTAMP:
-          if (value instanceof Timestamp) {
-            return (double) ((Timestamp) value).getTime();
-          } else {
-            if (isLiteral) {
-              Long l = (Long) value / 1000;
-              return l.doubleValue();
-            }
-            return (Double) (value);
-          }
-        default:
-          throw new FilterIllegalMemberException(
-              "Cannot convert" + this.getDataType().name() + " to double type value");
+          return (Double) (value);
+        }
+      } else {
+        throw new FilterIllegalMemberException(
+            "Cannot convert" + this.getDataType().getName() + " to double type value");
       }
     } catch (ClassCastException e) {
       throw new FilterIllegalMemberException(
-          "Cannot convert" + this.getDataType().name() + " to Double type value");
+          "Cannot convert" + this.getDataType().getName() + " to Double type value");
     }
   }
 
@@ -256,40 +251,40 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       return null;
     }
     try {
-      switch (this.getDataType()) {
-        case STRING:
-          try {
-            return Long.parseLong(value.toString());
-          } catch (NumberFormatException e) {
-            throw new FilterIllegalMemberException(e);
-          }
-        case SHORT:
-          return ((Short) value).longValue();
-        case INT:
-          return (Long) value;
-        case LONG:
+      DataType dataType = this.getDataType();
+      if (dataType == DataTypes.STRING) {
+        try {
+          return Long.parseLong(value.toString());
+        } catch (NumberFormatException e) {
+          throw new FilterIllegalMemberException(e);
+        }
+      } else if (dataType == DataTypes.SHORT) {
+        return ((Short) value).longValue();
+      } else if (dataType == DataTypes.INT) {
+        return (Long) value;
+      } else if (dataType == DataTypes.LONG) {
+        return (Long) value;
+      } else if (dataType == DataTypes.DOUBLE) {
+        return (Long) value;
+      } else if (dataType == DataTypes.DATE) {
+        if (value instanceof java.sql.Date) {
+          return ((java.sql.Date) value).getTime();
+        } else {
           return (Long) value;
-        case DOUBLE:
+        }
+      } else if (dataType == DataTypes.TIMESTAMP) {
+        if (value instanceof Timestamp) {
+          return ((Timestamp) value).getTime();
+        } else {
           return (Long) value;
-        case DATE:
-          if (value instanceof java.sql.Date) {
-            return ((java.sql.Date) value).getTime();
-          } else {
-            return (Long) value;
-          }
-        case TIMESTAMP:
-          if (value instanceof Timestamp) {
-            return ((Timestamp) value).getTime();
-          } else {
-            return (Long) value;
-          }
-        default:
-          throw new FilterIllegalMemberException(
-              "Cannot convert" + this.getDataType().name() + " to Long type value");
+        }
+      } else {
+        throw new FilterIllegalMemberException(
+            "Cannot convert" + this.getDataType().getName() + " to Long type value");
       }
     } catch (ClassCastException e) {
       throw new FilterIllegalMemberException(e.getMessage() + " " +
-          "Cannot convert" + this.getDataType().name() + " to Long type value");
+          "Cannot convert" + this.getDataType().getName() + " to Long type value");
     }
 
   }
@@ -300,44 +295,43 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       return null;
     }
     try {
-      switch (this.getDataType()) {
-        case STRING:
-          try {
-            return new BigDecimal(value.toString());
-          } catch (NumberFormatException e) {
-            throw new FilterIllegalMemberException(e);
-          }
-        case SHORT:
-          return new BigDecimal((short) value);
-        case INT:
-          return new BigDecimal((int) value);
-        case LONG:
-          return new BigDecimal((long) value);
-        case DOUBLE:
-        case DECIMAL:
+      DataType dataType = this.getDataType();
+      if (dataType == DataTypes.STRING) {
+        try {
           return new BigDecimal(value.toString());
-        case DATE:
-          if (value instanceof java.sql.Date) {
-            return new BigDecimal(((java.sql.Date) value).getTime());
-          } else {
-            return new BigDecimal((long) value);
-          }
-        case TIMESTAMP:
-          if (value instanceof Timestamp) {
-            return new BigDecimal(((Timestamp) value).getTime());
-          } else {
-            if (isLiteral) {
-              return new BigDecimal((long) value / 1000);
-            }
-            return new BigDecimal((long) value);
+        } catch (NumberFormatException e) {
+          throw new FilterIllegalMemberException(e);
+        }
+      } else if (dataType == DataTypes.SHORT) {
+        return new BigDecimal((short) value);
+      } else if (dataType == DataTypes.INT) {
+        return new BigDecimal((int) value);
+      } else if (dataType == DataTypes.LONG) {
+        return new BigDecimal((long) value);
+      } else if (dataType == DataTypes.DOUBLE || dataType == DataTypes.DECIMAL) {
+        return new BigDecimal(value.toString());
+      } else if (dataType == DataTypes.DATE) {
+        if (value instanceof java.sql.Date) {
+          return new BigDecimal(((java.sql.Date) value).getTime());
+        } else {
+          return new BigDecimal((long) value);
+        }
+      } else if (dataType == DataTypes.TIMESTAMP) {
+        if (value instanceof Timestamp) {
+          return new BigDecimal(((Timestamp) value).getTime());
+        } else {
+          if (isLiteral) {
+            return new BigDecimal((long) value / 1000);
           }
-        default:
-          throw new FilterIllegalMemberException(
-              "Cannot convert" + this.getDataType().name() + " to Long type value");
+          return new BigDecimal((long) value);
+        }
+      } else {
+        throw new FilterIllegalMemberException(
+            "Cannot convert" + this.getDataType().getName() + " to Decimal type value");
       }
     } catch (ClassCastException e) {
       throw new FilterIllegalMemberException(
-          "Cannot convert" + this.getDataType().name() + " to Long type value");
+          "Cannot convert" + this.getDataType().getName() + " to Decimal type value");
     }
 
   }
@@ -347,51 +341,50 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       return null;
     }
     try {
-      switch (this.getDataType()) {
-        case STRING:
-          // Currently the query engine layer only supports yyyy-MM-dd HH:mm:ss date format
-          // no matter in which format the data is been stored, so while retrieving the direct
-          // surrogate value for filter member first it should be converted in date form as per
-          // above format and needs to retrieve time stamp.
-          SimpleDateFormat parser =
-              new SimpleDateFormat(CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
-          Date dateToStr;
-          try {
-            dateToStr = parser.parse(value.toString());
-            return dateToStr.getTime();
-          } catch (ParseException e) {
-            throw new FilterIllegalMemberException(
-                "Cannot convert" + this.getDataType().name() + " to Time/Long type value");
-          }
-        case SHORT:
-          return ((Short) value).longValue();
-        case INT:
-        case LONG:
-          return (Long) value;
-        case DOUBLE:
+      DataType dataType = this.getDataType();
+      if (dataType == DataTypes.STRING) {
+        // Currently the query engine layer only supports yyyy-MM-dd HH:mm:ss date format
+        // no matter in which format the data is been stored, so while retrieving the direct
+        // surrogate value for filter member first it should be converted in date form as per
+        // above format and needs to retrieve time stamp.
+        SimpleDateFormat parser =
+            new SimpleDateFormat(CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
+        Date dateToStr;
+        try {
+          dateToStr = parser.parse(value.toString());
+          return dateToStr.getTime();
+        } catch (ParseException e) {
+          throw new FilterIllegalMemberException(
+              "Cannot convert" + this.getDataType().getName() + " to Time type value");
+        }
+      } else if (dataType == DataTypes.SHORT) {
+        return ((Short) value).longValue();
+      } else if (dataType == DataTypes.INT || dataType == DataTypes.LONG) {
+        return (Long) value;
+      } else if (dataType == DataTypes.DOUBLE) {
+        return (Long) value;
+      } else if (dataType == DataTypes.DATE) {
+        if (value instanceof java.sql.Date) {
+          return ((Date) value).getTime();
+        } else {
           return (Long) value;
-        case DATE:
-          if (value instanceof java.sql.Date) {
-            return ((Date) value).getTime();
-          } else {
-            return (Long) value;
-          }
-        case TIMESTAMP:
-          if (value instanceof Timestamp) {
-            return ((Timestamp) value).getTime();
-          } else {
-            if (isLiteral) {
-              return (Long) value / 1000;
-            }
-            return (Long) value;
+        }
+      } else if (dataType == DataTypes.TIMESTAMP) {
+        if (value instanceof Timestamp) {
+          return ((Timestamp) value).getTime();
+        } else {
+          if (isLiteral) {
+            return (Long) value / 1000;
           }
-        default:
-          throw new FilterIllegalMemberException(
-              "Cannot convert" + this.getDataType().name() + " to Time/Long type value");
+          return (Long) value;
+        }
+      } else {
+        throw new FilterIllegalMemberException(
+            "Cannot convert" + this.getDataType().getName() + " to Time type value");
       }
     } catch (ClassCastException e) {
       throw new FilterIllegalMemberException(
-          "Cannot convert" + this.getDataType().name() + " to Time/Long type value");
+          "Cannot convert" + this.getDataType().getName() + " to Time type value");
     }
 
   }
@@ -401,24 +394,22 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       return null;
     }
     try {
-      switch (this.getDataType()) {
-        case STRING:
-          try {
-            return Boolean.parseBoolean(value.toString());
-          } catch (NumberFormatException e) {
-            throw new FilterIllegalMemberException(e);
-          }
-
-        case BOOLEAN:
+      DataType dataType = this.getDataType();
+      if (dataType == DataTypes.STRING) {
+        try {
           return Boolean.parseBoolean(value.toString());
-
-        default:
-          throw new FilterIllegalMemberException(
-              "Cannot convert" + this.getDataType().name() + " to boolean type value");
+        } catch (NumberFormatException e) {
+          throw new FilterIllegalMemberException(e);
+        }
+      } else if (dataType == DataTypes.BOOLEAN) {
+        return Boolean.parseBoolean(value.toString());
+      } else {
+        throw new FilterIllegalMemberException(
+            "Cannot convert" + this.getDataType().getName() + " to boolean type value");
       }
     } catch (ClassCastException e) {
       throw new FilterIllegalMemberException(
-          "Cannot convert" + this.getDataType().name() + " to Boolean type value");
+          "Cannot convert" + this.getDataType().getName() + " to Boolean type value");
     }
   }
 
@@ -491,29 +482,20 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
       dataType = objToCompare.getDataType();
     }
     try {
-      switch (dataType) {
-        case STRING:
-          result = this.getString().equals(objToCompare.getString());
-          break;
-        case SHORT:
-          result = this.getShort().equals(objToCompare.getShort());
-          break;
-        case INT:
-          result = this.getInt().equals(objToCompare.getInt());
-          break;
-        case LONG:
-        case DATE:
-        case TIMESTAMP:
-          result = this.getLong().equals(objToCompare.getLong());
-          break;
-        case DOUBLE:
-          result = this.getDouble().equals(objToCompare.getDouble());
-          break;
-        case DECIMAL:
-          result = this.getDecimal().equals(objToCompare.getDecimal());
-          break;
-        default:
-          break;
+      if (dataType == DataTypes.STRING) {
+        result = this.getString().equals(objToCompare.getString());
+      } else if (dataType == DataTypes.SHORT) {
+        result = this.getShort().equals(objToCompare.getShort());
+      } else if (dataType == DataTypes.INT) {
+        result = this.getInt().equals(objToCompare.getInt());
+      } else if (dataType == DataTypes.LONG ||
+          dataType == DataTypes.DATE ||
+          dataType == DataTypes.TIMESTAMP) {
+        result = this.getLong().equals(objToCompare.getLong());
+      } else if (dataType == DataTypes.DOUBLE) {
+        result = this.getDouble().equals(objToCompare.getDouble());
+      } else if (dataType == DataTypes.DECIMAL) {
+        result = this.getDecimal().equals(objToCompare.getDecimal());
       }
     } catch (FilterIllegalMemberException ex) {
       return false;
@@ -528,32 +510,28 @@ public class ExpressionResult implements Comparable<ExpressionResult> {
 
   @Override public int compareTo(ExpressionResult o) {
     try {
-      switch (o.dataType) {
-        case SHORT:
-        case INT:
-        case LONG:
-        case DOUBLE:
-          Double d1 = this.getDouble();
-          Double d2 = o.getDouble();
-          return d1.compareTo(d2);
-        case DECIMAL:
-          java.math.BigDecimal val1 = this.getDecimal();
-          java.math.BigDecimal val2 = o.getDecimal();
-          return val1.compareTo(val2);
-        case DATE:
-        case TIMESTAMP:
-          String format = CarbonUtil.getFormatFromProperty(o.dataType);
-          SimpleDateFormat parser = new SimpleDateFormat(format);
-          Date date1 = parser.parse(this.getString());
-          Date date2 = parser.parse(o.getString());
-          return date1.compareTo(date2);
-        case STRING:
-        default:
-          return this.getString().compareTo(o.getString());
+      DataType type = o.dataType;
+      if (type == DataTypes.SHORT ||
+          type == DataTypes.INT ||
+          type == DataTypes.LONG ||
+          type == DataTypes.DOUBLE) {
+        Double d1 = this.getDouble();
+        Double d2 = o.getDouble();
+        return d1.compareTo(d2);
+      } else if (type == DataTypes.DECIMAL) {
+        java.math.BigDecimal val1 = this.getDecimal();
+        java.math.BigDecimal val2 = o.getDecimal();
+        return val1.compareTo(val2);
+      } else if (type == DataTypes.DATE || type == DataTypes.TIMESTAMP) {
+        String format = CarbonUtil.getFormatFromProperty(o.dataType);
+        SimpleDateFormat parser = new SimpleDateFormat(format);
+        Date date1 = parser.parse(this.getString());
+        Date date2 = parser.parse(o.getString());
+        return date1.compareTo(date2);
+      } else {
+        return this.getString().compareTo(o.getString());
       }
-    } catch (ParseException e) {
-      return -1;
-    } catch (FilterIllegalMemberException e) {
+    } catch (ParseException | FilterIllegalMemberException e) {
       return -1;
     }
   }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/RangeExpressionEvaluator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/RangeExpressionEvaluator.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/RangeExpressionEvaluator.java
index d98593c..9d418ee 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/RangeExpressionEvaluator.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/RangeExpressionEvaluator.java
@@ -27,6 +27,7 @@ import org.apache.carbondata.common.logging.LogService;
 import org.apache.carbondata.common.logging.LogServiceFactory;
 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.scan.expression.conditional.GreaterThanEqualToExpression;
 import org.apache.carbondata.core.scan.expression.conditional.GreaterThanExpression;
 import org.apache.carbondata.core.scan.expression.conditional.LessThanEqualToExpression;
@@ -279,8 +280,8 @@ public class RangeExpressionEvaluator {
         if (((ColumnExpression) exp).isDimension() == false) {
           return false;
         }
-        if ((((ColumnExpression) exp).getDimension().getDataType() == DataType.ARRAY) || (
-            ((ColumnExpression) exp).getDimension().getDataType() == DataType.STRUCT)) {
+        if ((((ColumnExpression) exp).getDimension().getDataType() == DataTypes.ARRAY) || (
+            ((ColumnExpression) exp).getDimension().getDataType() == DataTypes.STRUCT)) {
           return false;
         } else {
           return true;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/EqualToExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/EqualToExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/EqualToExpression.java
index bac54c8..780ca89 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/EqualToExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/EqualToExpression.java
@@ -18,6 +18,7 @@
 package org.apache.carbondata.core.scan.expression.conditional;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -51,9 +52,9 @@ public class EqualToExpression extends BinaryConditionalExpression {
 
     if (elRes.isNull() || erRes.isNull()) {
       if (isNull) {
-        elRes.set(DataType.BOOLEAN, elRes.isNull() == erRes.isNull());
+        elRes.set(DataTypes.BOOLEAN, elRes.isNull() == erRes.isNull());
       } else {
-        elRes.set(DataType.BOOLEAN, false);
+        elRes.set(DataTypes.BOOLEAN, false);
       }
       return elRes;
     }
@@ -65,34 +66,26 @@ public class EqualToExpression extends BinaryConditionalExpression {
       }
     }
 
-    switch (val1.getDataType()) {
-      case STRING:
-        result = val1.getString().equals(val2.getString());
-        break;
-      case SHORT:
-        result = val1.getShort().equals(val2.getShort());
-        break;
-      case INT:
-        result = val1.getInt().equals(val2.getInt());
-        break;
-      case DOUBLE:
-        result = FilterUtil.nanSafeEqualsDoubles(val1.getDouble(), val2.getDouble());
-        break;
-      case DATE:
-      case TIMESTAMP:
-        result = val1.getTime().equals(val2.getTime());
-        break;
-      case LONG:
-        result = val1.getLong().equals(val2.getLong());
-        break;
-      case DECIMAL:
-        result = val1.getDecimal().compareTo(val2.getDecimal()) == 0;
-        break;
-      default:
-        throw new FilterUnsupportedException(
-            "DataType: " + val1.getDataType() + " not supported for the filter expression");
+    DataType dataType = val1.getDataType();
+    if (dataType == DataTypes.STRING) {
+      result = val1.getString().equals(val2.getString());
+    } else if (dataType == DataTypes.SHORT) {
+      result = val1.getShort().equals(val2.getShort());
+    } else if (dataType == DataTypes.INT) {
+      result = val1.getInt().equals(val2.getInt());
+    } else if (dataType == DataTypes.DOUBLE) {
+      result = FilterUtil.nanSafeEqualsDoubles(val1.getDouble(), val2.getDouble());
+    } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+      result = val1.getTime().equals(val2.getTime());
+    } else if (dataType == DataTypes.LONG) {
+      result = val1.getLong().equals(val2.getLong());
+    } else if (dataType == DataTypes.DECIMAL) {
+      result = val1.getDecimal().compareTo(val2.getDecimal()) == 0;
+    } else {
+      throw new FilterUnsupportedException(
+          "DataType: " + val1.getDataType() + " not supported for the filter expression");
     }
-    val1.set(DataType.BOOLEAN, result);
+    val1.set(DataTypes.BOOLEAN, result);
     return val1;
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanEqualToExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanEqualToExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanEqualToExpression.java
index d51ff01..469672e 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanEqualToExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanEqualToExpression.java
@@ -18,6 +18,7 @@
 package org.apache.carbondata.core.scan.expression.conditional;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -38,7 +39,7 @@ public class GreaterThanEqualToExpression extends BinaryConditionalExpression {
     ExpressionResult erRes = right.evaluate(value);
     ExpressionResult exprResVal1 = elRes;
     if (elRes.isNull() || erRes.isNull()) {
-      elRes.set(DataType.BOOLEAN, false);
+      elRes.set(DataTypes.BOOLEAN, false);
       return elRes;
     }
     if (elRes.getDataType() != erRes.getDataType()) {
@@ -48,34 +49,26 @@ public class GreaterThanEqualToExpression extends BinaryConditionalExpression {
 
     }
     boolean result = false;
-    switch (exprResVal1.getDataType()) {
-      case STRING:
-        result = elRes.getString().compareTo(erRes.getString()) >= 0;
-        break;
-      case SHORT:
-        result = elRes.getShort() >= (erRes.getShort());
-        break;
-      case INT:
-        result = elRes.getInt() >= (erRes.getInt());
-        break;
-      case DOUBLE:
-        result = elRes.getDouble() >= (erRes.getDouble());
-        break;
-      case DATE:
-      case TIMESTAMP:
-        result = elRes.getTime() >= (erRes.getTime());
-        break;
-      case LONG:
-        result = elRes.getLong() >= (erRes.getLong());
-        break;
-      case DECIMAL:
-        result = elRes.getDecimal().compareTo(erRes.getDecimal()) >= 0;
-        break;
-      default:
-        throw new FilterUnsupportedException(
-            "DataType: " + exprResVal1.getDataType() + " not supported for the filter expression");
+    DataType dataType = exprResVal1.getDataType();
+    if (dataType == DataTypes.STRING) {
+      result = elRes.getString().compareTo(erRes.getString()) >= 0;
+    } else if (dataType == DataTypes.SHORT) {
+      result = elRes.getShort() >= (erRes.getShort());
+    } else if (dataType == DataTypes.INT) {
+      result = elRes.getInt() >= (erRes.getInt());
+    } else if (dataType == DataTypes.DOUBLE) {
+      result = elRes.getDouble() >= (erRes.getDouble());
+    } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+      result = elRes.getTime() >= (erRes.getTime());
+    } else if (dataType == DataTypes.LONG) {
+      result = elRes.getLong() >= (erRes.getLong());
+    } else if (dataType == DataTypes.DECIMAL) {
+      result = elRes.getDecimal().compareTo(erRes.getDecimal()) >= 0;
+    } else  {
+      throw new FilterUnsupportedException(
+          "DataType: " + exprResVal1.getDataType() + " not supported for the filter expression");
     }
-    exprResVal1.set(DataType.BOOLEAN, result);
+    exprResVal1.set(DataTypes.BOOLEAN, result);
     return exprResVal1;
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpression.java
index 2c3dd7e..931de6c 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/GreaterThanExpression.java
@@ -18,6 +18,7 @@
 package org.apache.carbondata.core.scan.expression.conditional;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -39,7 +40,7 @@ public class GreaterThanExpression extends BinaryConditionalExpression {
     ExpressionResult exprRightRes = right.evaluate(value);
     ExpressionResult val1 = exprLeftRes;
     if (exprLeftRes.isNull() || exprRightRes.isNull()) {
-      exprLeftRes.set(DataType.BOOLEAN, false);
+      exprLeftRes.set(DataTypes.BOOLEAN, false);
       return exprLeftRes;
     }
     if (exprLeftRes.getDataType() != exprRightRes.getDataType()) {
@@ -50,34 +51,26 @@ public class GreaterThanExpression extends BinaryConditionalExpression {
 
     }
     boolean result = false;
-    switch (val1.getDataType()) {
-      case STRING:
-        result = exprLeftRes.getString().compareTo(exprRightRes.getString()) > 0;
-        break;
-      case DOUBLE:
-        result = exprLeftRes.getDouble() > (exprRightRes.getDouble());
-        break;
-      case SHORT:
-        result = exprLeftRes.getShort() > (exprRightRes.getShort());
-        break;
-      case INT:
-        result = exprLeftRes.getInt() > (exprRightRes.getInt());
-        break;
-      case DATE:
-      case TIMESTAMP:
-        result = exprLeftRes.getTime() > (exprRightRes.getTime());
-        break;
-      case LONG:
-        result = exprLeftRes.getLong() > (exprRightRes.getLong());
-        break;
-      case DECIMAL:
-        result = exprLeftRes.getDecimal().compareTo(exprRightRes.getDecimal()) > 0;
-        break;
-      default:
-        throw new FilterUnsupportedException(
-            "DataType: " + val1.getDataType() + " not supported for the filter expression");
+    DataType dataType = val1.getDataType();
+    if (dataType == DataTypes.STRING) {
+      result = exprLeftRes.getString().compareTo(exprRightRes.getString()) > 0;
+    } else if (dataType == DataTypes.DOUBLE) {
+      result = exprLeftRes.getDouble() > (exprRightRes.getDouble());
+    } else if (dataType == DataTypes.SHORT) {
+      result = exprLeftRes.getShort() > (exprRightRes.getShort());
+    } else if (dataType == DataTypes.INT) {
+      result = exprLeftRes.getInt() > (exprRightRes.getInt());
+    } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+      result = exprLeftRes.getTime() > (exprRightRes.getTime());
+    } else if (dataType == DataTypes.LONG) {
+      result = exprLeftRes.getLong() > (exprRightRes.getLong());
+    } else if (dataType == DataTypes.DECIMAL) {
+      result = exprLeftRes.getDecimal().compareTo(exprRightRes.getDecimal()) > 0;
+    } else {
+      throw new FilterUnsupportedException(
+          "DataType: " + val1.getDataType() + " not supported for the filter expression");
     }
-    val1.set(DataType.BOOLEAN, result);
+    val1.set(DataTypes.BOOLEAN, result);
     return val1;
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/InExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/InExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/InExpression.java
index 130063d..bc714f7 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/InExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/InExpression.java
@@ -21,6 +21,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -52,32 +53,24 @@ public class InExpression extends BinaryConditionalExpression {
         } else {
           val = expressionResVal;
         }
-        switch (val.getDataType()) {
-          case STRING:
-            val = new ExpressionResult(val.getDataType(), expressionResVal.getString());
-            break;
-          case SHORT:
-            val = new ExpressionResult(val.getDataType(), expressionResVal.getShort());
-            break;
-          case INT:
-            val = new ExpressionResult(val.getDataType(), expressionResVal.getInt());
-            break;
-          case DOUBLE:
-            val = new ExpressionResult(val.getDataType(), expressionResVal.getDouble());
-            break;
-          case LONG:
-            val = new ExpressionResult(val.getDataType(), expressionResVal.getLong());
-            break;
-          case DATE:
-          case TIMESTAMP:
-            val = new ExpressionResult(val.getDataType(), expressionResVal.getTime());
-            break;
-          case DECIMAL:
-            val = new ExpressionResult(val.getDataType(), expressionResVal.getDecimal());
-            break;
-          default:
-            throw new FilterUnsupportedException(
-                "DataType: " + val.getDataType() + " not supported for the filter expression");
+        DataType dataType = val.getDataType();
+        if (dataType == DataTypes.STRING) {
+          val = new ExpressionResult(val.getDataType(), expressionResVal.getString());
+        } else if (dataType == DataTypes.SHORT) {
+          val = new ExpressionResult(val.getDataType(), expressionResVal.getShort());
+        } else if (dataType == DataTypes.INT) {
+          val = new ExpressionResult(val.getDataType(), expressionResVal.getInt());
+        } else if (dataType == DataTypes.DOUBLE) {
+          val = new ExpressionResult(val.getDataType(), expressionResVal.getDouble());
+        } else if (dataType == DataTypes.LONG) {
+          val = new ExpressionResult(val.getDataType(), expressionResVal.getLong());
+        } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+          val = new ExpressionResult(val.getDataType(), expressionResVal.getTime());
+        } else if (dataType == DataTypes.DECIMAL) {
+          val = new ExpressionResult(val.getDataType(), expressionResVal.getDecimal());
+        } else {
+          throw new FilterUnsupportedException(
+              "DataType: " + val.getDataType() + " not supported for the filter expression");
         }
         setOfExprResult.add(val);
       }
@@ -91,9 +84,9 @@ public class InExpression extends BinaryConditionalExpression {
     // for a check on the right result.
     // Example: (null==null) -> Left null return false, (1==null) would automatically be false.
     if (leftRsult.isNull()) {
-      leftRsult.set(DataType.BOOLEAN, false);
+      leftRsult.set(DataTypes.BOOLEAN, false);
     } else {
-      leftRsult.set(DataType.BOOLEAN, setOfExprResult.contains(leftRsult));
+      leftRsult.set(DataTypes.BOOLEAN, setOfExprResult.contains(leftRsult));
     }
     return leftRsult;
   }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpression.java
index d61498b..f416a6b 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanEqualToExpression.java
@@ -18,6 +18,7 @@
 package org.apache.carbondata.core.scan.expression.conditional;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -38,7 +39,7 @@ public class LessThanEqualToExpression extends BinaryConditionalExpression {
     ExpressionResult erRes = right.evaluate(value);
     ExpressionResult exprResValue1 = elRes;
     if (elRes.isNull() || erRes.isNull()) {
-      elRes.set(DataType.BOOLEAN, false);
+      elRes.set(DataTypes.BOOLEAN, false);
       return elRes;
     }
     if (elRes.getDataType() != erRes.getDataType()) {
@@ -48,34 +49,26 @@ public class LessThanEqualToExpression extends BinaryConditionalExpression {
 
     }
     boolean result = false;
-    switch (exprResValue1.getDataType()) {
-      case STRING:
-        result = elRes.getString().compareTo(erRes.getString()) <= 0;
-        break;
-      case SHORT:
-        result = elRes.getShort() <= (erRes.getShort());
-        break;
-      case INT:
-        result = elRes.getInt() <= (erRes.getInt());
-        break;
-      case DOUBLE:
-        result = elRes.getDouble() <= (erRes.getDouble());
-        break;
-      case DATE:
-      case TIMESTAMP:
-        result = elRes.getTime() <= (erRes.getTime());
-        break;
-      case LONG:
-        result = elRes.getLong() <= (erRes.getLong());
-        break;
-      case DECIMAL:
-        result = elRes.getDecimal().compareTo(erRes.getDecimal()) <= 0;
-        break;
-      default:
-        throw new FilterUnsupportedException("DataType: " + exprResValue1.getDataType()
-            + " not supported for the filter expression");
+    DataType dataType = exprResValue1.getDataType();
+    if (dataType == DataTypes.STRING) {
+      result = elRes.getString().compareTo(erRes.getString()) <= 0;
+    } else if (dataType == DataTypes.SHORT) {
+      result = elRes.getShort() <= (erRes.getShort());
+    } else if (dataType == DataTypes.INT) {
+      result = elRes.getInt() <= (erRes.getInt());
+    } else if (dataType == DataTypes.DOUBLE) {
+      result = elRes.getDouble() <= (erRes.getDouble());
+    } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+      result = elRes.getTime() <= (erRes.getTime());
+    } else if (dataType == DataTypes.LONG) {
+      result = elRes.getLong() <= (erRes.getLong());
+    } else if (dataType == DataTypes.DECIMAL) {
+      result = elRes.getDecimal().compareTo(erRes.getDecimal()) <= 0;
+    } else {
+      throw new FilterUnsupportedException("DataType: " + exprResValue1.getDataType()
+          + " not supported for the filter expression");
     }
-    exprResValue1.set(DataType.BOOLEAN, result);
+    exprResValue1.set(DataTypes.BOOLEAN, result);
     return exprResValue1;
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpression.java
index b06b389..c0d7c10 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/LessThanExpression.java
@@ -18,6 +18,7 @@
 package org.apache.carbondata.core.scan.expression.conditional;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -43,7 +44,7 @@ public class LessThanExpression extends BinaryConditionalExpression {
     boolean result = false;
 
     if (elRes.isNull() || erRes.isNull()) {
-      elRes.set(DataType.BOOLEAN, false);
+      elRes.set(DataTypes.BOOLEAN, false);
       return elRes;
     }
     if (elRes.getDataType() != erRes.getDataType()) {
@@ -52,34 +53,26 @@ public class LessThanExpression extends BinaryConditionalExpression {
       }
 
     }
-    switch (val1.getDataType()) {
-      case STRING:
-        result = elRes.getString().compareTo(erRes.getString()) < 0;
-        break;
-      case SHORT:
-        result = elRes.getShort() < (erRes.getShort());
-        break;
-      case INT:
-        result = elRes.getInt() < (erRes.getInt());
-        break;
-      case DOUBLE:
-        result = elRes.getDouble() < (erRes.getDouble());
-        break;
-      case DATE:
-      case TIMESTAMP:
-        result = elRes.getTime() < (erRes.getTime());
-        break;
-      case LONG:
-        result = elRes.getLong() < (erRes.getLong());
-        break;
-      case DECIMAL:
-        result = elRes.getDecimal().compareTo(erRes.getDecimal()) < 0;
-        break;
-      default:
-        throw new FilterUnsupportedException(
-            "DataType: " + val1.getDataType() + " not supported for the filter expression");
+    DataType dataType = val1.getDataType();
+    if (dataType == DataTypes.STRING) {
+      result = elRes.getString().compareTo(erRes.getString()) < 0;
+    } else if (dataType == DataTypes.SHORT) {
+      result = elRes.getShort() < (erRes.getShort());
+    } else if (dataType == DataTypes.INT) {
+      result = elRes.getInt() < (erRes.getInt());
+    } else if (dataType == DataTypes.DOUBLE) {
+      result = elRes.getDouble() < (erRes.getDouble());
+    } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+      result = elRes.getTime() < (erRes.getTime());
+    } else if (dataType == DataTypes.LONG) {
+      result = elRes.getLong() < (erRes.getLong());
+    } else if (dataType == DataTypes.DECIMAL) {
+      result = elRes.getDecimal().compareTo(erRes.getDecimal()) < 0;
+    } else {
+      throw new FilterUnsupportedException("DataType: " + val1.getDataType() +
+          " not supported for the filter expression");
     }
-    val1.set(DataType.BOOLEAN, result);
+    val1.set(DataTypes.BOOLEAN, result);
     return val1;
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpression.java
index f139802..8930c94 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotEqualsExpression.java
@@ -18,6 +18,7 @@
 package org.apache.carbondata.core.scan.expression.conditional;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -48,9 +49,9 @@ public class NotEqualsExpression extends BinaryConditionalExpression {
     ExpressionResult val2 = erRes;
     if (elRes.isNull() || erRes.isNull()) {
       if (isNotNull) {
-        elRes.set(DataType.BOOLEAN, elRes.isNull() != erRes.isNull());
+        elRes.set(DataTypes.BOOLEAN, elRes.isNull() != erRes.isNull());
       } else {
-        elRes.set(DataType.BOOLEAN, false);
+        elRes.set(DataTypes.BOOLEAN, false);
       }
       return elRes;
     }
@@ -61,34 +62,26 @@ public class NotEqualsExpression extends BinaryConditionalExpression {
         val2 = elRes;
       }
     }
-    switch (val1.getDataType()) {
-      case STRING:
-        result = !val1.getString().equals(val2.getString());
-        break;
-      case SHORT:
-        result = val1.getShort().shortValue() != val2.getShort().shortValue();
-        break;
-      case INT:
-        result = val1.getInt().intValue() != val2.getInt().intValue();
-        break;
-      case DOUBLE:
-        result = val1.getDouble().doubleValue() != val2.getDouble().doubleValue();
-        break;
-      case DATE:
-      case TIMESTAMP:
-        result = val1.getTime().longValue() != val2.getTime().longValue();
-        break;
-      case LONG:
-        result = elRes.getLong().longValue() != (erRes.getLong()).longValue();
-        break;
-      case DECIMAL:
-        result = elRes.getDecimal().compareTo(erRes.getDecimal()) != 0;
-        break;
-      default:
-        throw new FilterUnsupportedException(
-            "DataType: " + val1.getDataType() + " not supported for the filter expression");
+    DataType dataType = val1.getDataType();
+    if (dataType == DataTypes.STRING) {
+      result = !val1.getString().equals(val2.getString());
+    } else if (dataType == DataTypes.SHORT) {
+      result = val1.getShort().shortValue() != val2.getShort().shortValue();
+    } else if (dataType == DataTypes.INT) {
+      result = val1.getInt().intValue() != val2.getInt().intValue();
+    } else if (dataType == DataTypes.DOUBLE) {
+      result = val1.getDouble().doubleValue() != val2.getDouble().doubleValue();
+    } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+      result = val1.getTime().longValue() != val2.getTime().longValue();
+    } else if (dataType == DataTypes.LONG) {
+      result = elRes.getLong().longValue() != (erRes.getLong()).longValue();
+    } else if (dataType == DataTypes.DECIMAL) {
+      result = elRes.getDecimal().compareTo(erRes.getDecimal()) != 0;
+    } else {
+      throw new FilterUnsupportedException(
+          "DataType: " + val1.getDataType() + " not supported for the filter expression");
     }
-    val1.set(DataType.BOOLEAN, result);
+    val1.set(DataTypes.BOOLEAN, result);
     return val1;
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
index 9f385ec..5f6359b 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
@@ -21,6 +21,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -51,7 +52,7 @@ public class NotInExpression extends BinaryConditionalExpression {
 
     ExpressionResult leftRsult = left.evaluate(value);
     if (leftRsult.isNull()) {
-      leftRsult.set(DataType.BOOLEAN, false);
+      leftRsult.set(DataTypes.BOOLEAN, false);
       return leftRsult;
     }
 
@@ -62,8 +63,8 @@ public class NotInExpression extends BinaryConditionalExpression {
       for (ExpressionResult exprResVal : rightRsult.getList()) {
 
         if (exprResVal.isNull()) {
-          nullValuePresent = new ExpressionResult(DataType.BOOLEAN, false);
-          leftRsult.set(DataType.BOOLEAN, false);
+          nullValuePresent = new ExpressionResult(DataTypes.BOOLEAN, false);
+          leftRsult.set(DataTypes.BOOLEAN, false);
           return leftRsult;
         }
 
@@ -73,39 +74,31 @@ public class NotInExpression extends BinaryConditionalExpression {
         } else {
           val = exprResVal;
         }
-        switch (val.getDataType()) {
-          case STRING:
-            val = new ExpressionResult(val.getDataType(), exprResVal.getString());
-            break;
-          case SHORT:
-            val = new ExpressionResult(val.getDataType(), exprResVal.getShort());
-            break;
-          case INT:
-            val = new ExpressionResult(val.getDataType(), exprResVal.getInt());
-            break;
-          case DOUBLE:
-            val = new ExpressionResult(val.getDataType(), exprResVal.getDouble());
-            break;
-          case DATE:
-          case TIMESTAMP:
-            val = new ExpressionResult(val.getDataType(), exprResVal.getTime());
-            break;
-          case LONG:
-            val = new ExpressionResult(val.getDataType(), exprResVal.getLong());
-            break;
-          case DECIMAL:
-            val = new ExpressionResult(val.getDataType(), exprResVal.getDecimal());
-            break;
-          default:
-            throw new FilterUnsupportedException(
-                "DataType: " + val.getDataType() + " not supported for the filter expression");
+        DataType dataType = val.getDataType();
+        if (dataType == DataTypes.STRING) {
+          val = new ExpressionResult(val.getDataType(), exprResVal.getString());
+        } else if (dataType == DataTypes.SHORT) {
+          val = new ExpressionResult(val.getDataType(), exprResVal.getShort());
+        } else if (dataType == DataTypes.INT) {
+          val = new ExpressionResult(val.getDataType(), exprResVal.getInt());
+        } else if (dataType == DataTypes.DOUBLE) {
+          val = new ExpressionResult(val.getDataType(), exprResVal.getDouble());
+        } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+          val = new ExpressionResult(val.getDataType(), exprResVal.getTime());
+        } else if (dataType == DataTypes.LONG) {
+          val = new ExpressionResult(val.getDataType(), exprResVal.getLong());
+        } else if (dataType == DataTypes.DECIMAL) {
+          val = new ExpressionResult(val.getDataType(), exprResVal.getDecimal());
+        } else {
+          throw new FilterUnsupportedException(
+              "DataType: " + val.getDataType() + " not supported for the filter expression");
         }
 
         setOfExprResult.add(val);
       }
     }
 
-    leftRsult.set(DataType.BOOLEAN, !setOfExprResult.contains(leftRsult));
+    leftRsult.set(DataTypes.BOOLEAN, !setOfExprResult.contains(leftRsult));
     return leftRsult;
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/AndExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/AndExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/AndExpression.java
index 58d650a..4a3508b 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/AndExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/AndExpression.java
@@ -17,7 +17,7 @@
 
 package org.apache.carbondata.core.scan.expression.logical;
 
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -37,13 +37,11 @@ public class AndExpression extends BinaryLogicalExpression {
       throws FilterUnsupportedException, FilterIllegalMemberException {
     ExpressionResult resultLeft = left.evaluate(value);
     ExpressionResult resultRight = right.evaluate(value);
-    switch (resultLeft.getDataType()) {
-      case BOOLEAN:
-        resultLeft.set(DataType.BOOLEAN, (resultLeft.getBoolean() && resultRight.getBoolean()));
-        break;
-      default:
-        throw new FilterUnsupportedException(
-            "Incompatible datatype for applying AND Expression Filter");
+    if (resultLeft.getDataType() == DataTypes.BOOLEAN) {
+      resultLeft.set(DataTypes.BOOLEAN, (resultLeft.getBoolean() && resultRight.getBoolean()));
+    } else {
+      throw new FilterUnsupportedException(
+          "Incompatible datatype for applying AND Expression Filter");
     }
     return resultLeft;
   }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/FalseExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/FalseExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/FalseExpression.java
index c2aab0f..f62980b 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/FalseExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/FalseExpression.java
@@ -17,7 +17,7 @@
 
 package org.apache.carbondata.core.scan.expression.logical;
 
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.LiteralExpression;
@@ -52,7 +52,7 @@ public class FalseExpression  extends BinaryConditionalExpression {
    */
   @Override public ExpressionResult evaluate(RowIntf value)
       throws FilterUnsupportedException, FilterIllegalMemberException {
-    return new ExpressionResult(DataType.BOOLEAN,false);
+    return new ExpressionResult(DataTypes.BOOLEAN,false);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/OrExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/OrExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/OrExpression.java
index a37251a..bd10f10 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/OrExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/OrExpression.java
@@ -17,7 +17,7 @@
 
 package org.apache.carbondata.core.scan.expression.logical;
 
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
@@ -37,15 +37,12 @@ public class OrExpression extends BinaryLogicalExpression {
       throws FilterIllegalMemberException, FilterUnsupportedException {
     ExpressionResult resultLeft = left.evaluate(value);
     ExpressionResult resultRight = right.evaluate(value);
-    switch (resultLeft.getDataType()) {
-      case BOOLEAN:
-        resultLeft.set(DataType.BOOLEAN, (resultLeft.getBoolean() || resultRight.getBoolean()));
-        break;
-      default:
-        throw new FilterUnsupportedException(
-            "Incompatible datatype for applying OR Expression Filter");
+    if (resultLeft.getDataType() == DataTypes.BOOLEAN) {
+      resultLeft.set(DataTypes.BOOLEAN, (resultLeft.getBoolean() || resultRight.getBoolean()));
+    } else {
+      throw new FilterUnsupportedException(
+          "Incompatible datatype for applying OR Expression Filter");
     }
-
     return resultLeft;
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/RangeExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/RangeExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/RangeExpression.java
index bce9320..01e3270 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/RangeExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/RangeExpression.java
@@ -22,7 +22,7 @@ import java.util.Collections;
 import java.util.List;
 
 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.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.LiteralExpression;
@@ -44,13 +44,11 @@ public class RangeExpression extends BinaryConditionalExpression {
       throws FilterUnsupportedException, FilterIllegalMemberException {
     ExpressionResult resultLeft = left.evaluate(value);
     ExpressionResult resultRight = right.evaluate(value);
-    switch (resultLeft.getDataType()) {
-      case BOOLEAN:
-        resultLeft.set(DataType.BOOLEAN, (resultLeft.getBoolean() && resultRight.getBoolean()));
-        break;
-      default:
-        throw new FilterUnsupportedException(
-            "Incompatible datatype for applying RANGE Expression Filter");
+    if (resultLeft.getDataType() == DataTypes.BOOLEAN) {
+      resultLeft.set(DataTypes.BOOLEAN, (resultLeft.getBoolean() && resultRight.getBoolean()));
+    } else {
+      throw new FilterUnsupportedException(
+          "Incompatible datatype for applying RANGE Expression Filter");
     }
     return resultLeft;
   }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/TrueExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/TrueExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/TrueExpression.java
index 7897f4a..39db1d2 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/TrueExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/logical/TrueExpression.java
@@ -17,7 +17,7 @@
 
 package org.apache.carbondata.core.scan.expression.logical;
 
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.Expression;
 import org.apache.carbondata.core.scan.expression.ExpressionResult;
 import org.apache.carbondata.core.scan.expression.LiteralExpression;
@@ -50,7 +50,7 @@ public class TrueExpression extends BinaryConditionalExpression {
    */
   @Override public ExpressionResult evaluate(RowIntf value)
       throws FilterUnsupportedException, FilterIllegalMemberException {
-    return new ExpressionResult(DataType.BOOLEAN,true);
+    return new ExpressionResult(DataTypes.BOOLEAN,true);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessor.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessor.java
index 1290f8b..68787e3 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessor.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterExpressionProcessor.java
@@ -30,7 +30,7 @@ import org.apache.carbondata.core.datastore.block.AbstractIndex;
 import org.apache.carbondata.core.datastore.impl.btree.BTreeDataRefNodeFinder;
 import org.apache.carbondata.core.keygenerator.KeyGenException;
 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.PartitionInfo;
 import org.apache.carbondata.core.scan.expression.BinaryExpression;
@@ -404,9 +404,9 @@ public class FilterExpressionProcessor implements FilterProcessor {
         currentCondExpression = (BinaryConditionalExpression) expression;
         if (currentCondExpression.isSingleColumn()
             && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType()
-            != DataType.ARRAY
+            != DataTypes.ARRAY
             && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType()
-            != DataType.STRUCT) {
+            != DataTypes.STRUCT) {
 
           if (currentCondExpression.getColumnList().get(0).getCarbonColumn().isMeasure()) {
             if (FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getLeft())
@@ -465,9 +465,9 @@ public class FilterExpressionProcessor implements FilterProcessor {
         currentCondExpression = (BinaryConditionalExpression) expression;
         if (currentCondExpression.isSingleColumn()
             && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType()
-            != DataType.ARRAY
+            != DataTypes.ARRAY
             && currentCondExpression.getColumnList().get(0).getCarbonColumn().getDataType()
-            != DataType.STRUCT) {
+            != DataTypes.STRUCT) {
 
           if (currentCondExpression.getColumnList().get(0).getCarbonColumn().isMeasure()) {
             if (FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getLeft())
@@ -524,9 +524,9 @@ public class FilterExpressionProcessor implements FilterProcessor {
           condExpression = (ConditionalExpression) expression;
           if (condExpression.isSingleColumn()
               && condExpression.getColumnList().get(0).getCarbonColumn().getDataType()
-              != DataType.ARRAY
+              != DataTypes.ARRAY
               && condExpression.getColumnList().get(0).getCarbonColumn().getDataType()
-              != DataType.STRUCT) {
+              != DataTypes.STRUCT) {
             condExpression = (ConditionalExpression) expression;
             if ((condExpression.getColumnList().get(0).getCarbonColumn()
                 .hasEncoding(Encoding.DICTIONARY) && !condExpression.getColumnList().get(0)


Mime
View raw message