public static byte findType(Object o) {
    if (o == null) {
      return NULL;
    }

    Class<?> clazz = o.getClass();

    // Try to put the most common first
    if (clazz == String.class) {
      return STRING;
    } else if (clazz == Integer.class) {
      return INTEGER;
    } else if (clazz == Long.class) {
      return LONG;
    } else if (clazz == Float.class) {
      return FLOAT;
    } else if (clazz == Double.class) {
      return DOUBLE;
    } else if (clazz == Boolean.class) {
      return BOOLEAN;
    } else if (clazz == Byte.class) {
      return BYTE;
    } else if (clazz == Short.class) {
      return SHORT;
    } else if (o instanceof List<?>) {
      return LIST;
    } else if (o instanceof Map<?, ?>) {
      return MAP;
    } else if (o instanceof byte[]) {
      return BINARY;
    } else if(o instanceof HiveChar) {
      return CHAR;
    } else if(o instanceof HiveVarchar) {
      return VARCHAR;
    } else if(o instanceof HiveDecimal) {
      return DECIMAL;
    } else if(o instanceof Date) {
      return DATE;
    } else if(o instanceof Timestamp) {
      return TIMESTAMP;
    } else {
      return ERROR;
    }
  }
Determine the datatype of an object.
@param o Object to test.
@return byte code of the type, or ERROR if we don't know.
hcatalog/core/src/main/java/org/apache/hive/hcatalog/data/DataType.java