Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.10.0
-
Patch
Description
We are currently migrating Hive UDF to Flink. While testing compatibility, we found that Flink cannot support primitive types like boolean, int, etc.
Hive UDF:
public class UDFTest extends UDF {
public boolean evaluate(String content) {
if (StringUtils.isEmpty(content))
else
{ return true; }}
}
We found that the following error will be reported:
Caused by: org.apache.flink.table.functions.hive.FlinkHiveUDFException: Class boolean is not supported yet
at org.apache.flink.table.functions.hive.conversion.HiveInspectors.getObjectInspector(HiveInspectors.java:372)
at org.apache.flink.table.functions.hive.HiveSimpleUDF.getHiveResultType(HiveSimpleUDF.java:133)
I found that if I add the type comparison in HiveInspectors.getObjectInspector to the primitive type, I can get the correct result.
as follows:
public static ObjectInspector getObjectInspector(HiveShim hiveShim, Class clazz){
..........
else if (clazz.equals(boolean.class) || clazz.equals(Boolean.class) || clazz.equals(BooleanWritable.class))
{ typeInfo = TypeInfoFactory.booleanTypeInfo; }..........
}