Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-17334

Flink does not support HIVE UDFs with primitive return types

    XMLWordPrintableJSON

    Details

    • Flags:
      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))

      { 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;                                 }

               ..........

      }

       

       

        Attachments

          Activity

            People

            • Assignee:
              royruan xin.ruan
              Reporter:
              royruan xin.ruan
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 72h
                72h
                Remaining:
                Remaining Estimate - 72h
                72h
                Logged:
                Time Spent - Not Specified
                Not Specified