snuyanzin commented on code in PR #22717:
URL: https://github.com/apache/flink/pull/22717#discussion_r1223337801
##########
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");
Review Comment:
I didn't get it...
for the case of one array `arrays.length == 1` and it will not enter this
`if`.
Also having just one array is ok, in that case we can just return it back.
Why are we talking about `"need at least two arrays"` ?
--
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]