You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/04/13 01:24:55 UTC

[GitHub] [flink] luoyuxia commented on a diff in pull request #19423: [FLINK-27175][hive] Support to call Hive UDAF when the UDAF accepts one parameter with array type

luoyuxia commented on code in PR #19423:
URL: https://github.com/apache/flink/pull/19423#discussion_r848990971


##########
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/functions/hive/HiveGenericUDAF.java:
##########
@@ -173,6 +178,14 @@ public GenericUDAFEvaluator.AggregationBuffer createAccumulator() {
 
     public void accumulate(GenericUDAFEvaluator.AggregationBuffer acc, Object... inputs)
             throws HiveException {
+        // When the parameter of the function is (Integer, Array[Double]), Flink calls
+        // udf.eval(AggregationBuffer, Integer, Array[Double]), which is not a problem.
+        // But when the parameter is a single array, Flink calls udf.accumulate(AggregationBuffer,
+        // Array[Double]), at this point java's var-args will cast Array[Double] to Array[Object]
+        // and let it be Object... args, So we need wrap it.
+        if (isArgsSingleArray) {
+            inputs = new Object[] {inputs};
+        }
         if (!allIdentityConverter) {
             for (int i = 0; i < inputs.length; i++) {

Review Comment:
   That's why we should make this change. When argsType is array, we will wrap the inputs to array so that the length will be 1.



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

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

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