lirui-apache commented on pull request #11876:
URL: https://github.com/apache/flink/pull/11876#issuecomment-618788643


   @Ruan-Xin I meant you can change `HiveSimpleUDF::getHiveResultType` to 
something like this:
   ```
        @Override
        public DataType getHiveResultType(Object[] constantArguments, 
DataType[] argTypes) {
                try {
                        List<TypeInfo> argTypeInfo = new ArrayList<>();
                        for (DataType argType : argTypes) {
                                
argTypeInfo.add(HiveTypeUtil.toHiveTypeInfo(argType, false));
                        }
                        Method evalMethod = 
hiveFunctionWrapper.createFunction().getResolver().getEvalMethod(argTypeInfo);
   
                        return HiveTypeUtil.toFlinkType(
                                        
ObjectInspectorFactory.getReflectionObjectInspector(evalMethod.getGenericReturnType(),
                                                        
ObjectInspectorFactory.ObjectInspectorOptions.JAVA));
                } catch (UDFArgumentException e) {
                        throw new FlinkHiveUDFException(e);
                }
        }
   ```
   So you don't have to handle key/value types by yourself. I haven't done 
thorough tests for this change but seems it works for simple cases at least.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to