[GitHub] [flink] lirui-apache commented on pull request #11876: [FLINK-17334] HIVE UDF BUGFIX

2020-04-26 Thread GitBox


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


   @Ruan-Xin Thanks for the update. Some suggestions about the current PR:
   1. Please make sure to follow flink's code style which will be verified by 
the CI system. You can refer to the wiki page for guidances: 
https://flink.apache.org/contributing/code-style-and-quality-preamble.html
   2. We already have a test class for UDFs: `HiveSimpleUDFTest`. Please add 
new tests in that class. And you don't have to add a java file for each UDF 
implementation -- just use inner classes will be fine.



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




[GitHub] [flink] lirui-apache commented on pull request #11876: [FLINK-17334] HIVE UDF BUGFIX

2020-04-23 Thread GitBox


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 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