snuyanzin commented on code in PR #22717:
URL: https://github.com/apache/flink/pull/22717#discussion_r1223346783
##########
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) {
+ if (arrays == null || arrays.length < 1) {
+ throw new ValidationException("need at least two arrays");
+ }
+ int numberOfNull = 0;
+ InType notNullArray = null;
+ for (int i = 0; i < arrays.length; ++i) {
+ if (arrays[i] == null) {
+ numberOfNull++;
+ } else {
+ notNullArray = arrays[i];
Review Comment:
looks like it takes into account only last `notNullArray`, is it expected?
--
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]