hanyuzheng7 commented on code in PR #22717:
URL: https://github.com/apache/flink/pull/22717#discussion_r1223408668


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/BaseExpressions.java:
##########
@@ -1407,6 +1409,44 @@ public OutType arrayUnion(InType array) {
                 unresolvedCall(ARRAY_UNION, toExpr(), 
objectToExpression(array)));
     }
 
+    /**
+     * Returns an array of the elements in the concat of array1 and array2, 
without duplicates.
+     *
+     * <p>If both of the array are null, the function will return null.
+     */
+    public OutType arrayConcat(InType... arrays) {
+        arrays = convertToArrays(arrays);
+        Expression[] args =
+                Stream.concat(
+                                Stream.of(toExpr()),
+                                
Arrays.stream(arrays).map(ApiExpressionUtils::objectToExpression))
+                        .toArray(Expression[]::new);
+        return toApiSpecificExpression(unresolvedCall(ARRAY_CONCAT, args));
+    }
+
+    private InType[] convertToArrays(InType[] arrays) {

Review Comment:
   Yes, we do. Because In Java, the varargs ... treats a single argument as a 
standalone argument rather than an array of arguments. Therefore, If I pass an 
argument [[1,2,3]] to a method that accepts InType... arrays, Java will treat 
it as [1,2,3], not [[1,2,3]].  If I pass array[[1,2,3]] to the Intype... this 
time arrays[0] is not [1,2,3] it will become 1,  and when you run the test 
cases, if will from array_concat(f0, array[1,2,3]) become to array_concat(f0, 
1, 2, 3), but I want to concat f0 and array[1,2,3] but not concat f0 with 1, 2, 
3



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to