TypeInfo oiTypeInfo1 = children.get(1).getTypeInfo();
SessionState ss = SessionState.get();
Configuration conf = (ss != null) ? ss.getConf() : new Configuration();
LogHelper console = new LogHelper(LOG);
// For now, if a bigint is going to be cast to a double throw an error or warning
if ((oiTypeInfo0.equals(TypeInfoFactory.stringTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) ||
(oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.stringTypeInfo))) {
if (HiveConf.getVar(conf, HiveConf.ConfVars.HIVEMAPREDMODE).equalsIgnoreCase("strict")) {
throw new UDFArgumentException(ErrorMsg.NO_COMPARE_BIGINT_STRING.getMsg());
} else {
console.printError("WARNING: Comparing a bigint and a string may result in a loss of precision.");
}
} else if ((oiTypeInfo0.equals(TypeInfoFactory.doubleTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.longTypeInfo)) ||
(oiTypeInfo0.equals(TypeInfoFactory.longTypeInfo) && oiTypeInfo1.equals(TypeInfoFactory.doubleTypeInfo))) {
if (HiveConf.getVar(conf, HiveConf.ConfVars.HIVEMAPREDMODE).equalsIgnoreCase("strict")) {
throw new UDFArgumentException(ErrorMsg.NO_COMPARE_BIGINT_DOUBLE.getMsg());
} else {
console.printError("WARNING: Comparing a bigint and a double may result in a loss of precision.");
}
}
}
ObjectInspector oi = genericUDF.initializeAndFoldConstants(childrenOIs);