[ https://issues.apache.org/jira/browse/FLINK-17334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17095031#comment-17095031 ]
xin.ruan commented on FLINK-17334: ---------------------------------- ok > Flink does not support HIVE UDFs with primitive return types > ------------------------------------------------------------- > > Key: FLINK-17334 > URL: https://issues.apache.org/jira/browse/FLINK-17334 > Project: Flink > Issue Type: Bug > Components: Connectors / Hive > Affects Versions: 1.10.0 > Reporter: xin.ruan > Assignee: xin.ruan > Priority: Major > Labels: pull-request-available > Fix For: 1.10.1 > > Original Estimate: 72h > Remaining Estimate: 72h > > 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)) > { return false; } > 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; } > .......... > } > > -- This message was sent by Atlassian Jira (v8.3.4#803005)