JiajunBernoulli commented on code in PR #3237:
URL: https://github.com/apache/calcite/pull/3237#discussion_r1225037630
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -4102,6 +4102,45 @@ public static List reverse(List list) {
return list;
}
+ /** SQL {@code ARRAY_TO_STRING(array, delimiter)} function. */
+ public static String arrayToString(List list, String delimiter) {
+ return arrayToString(list, delimiter, null);
+ }
+
+ /** SQL {@code ARRAY_TO_STRING(array, delimiter, nullText)} function. */
+ public static String arrayToString(List list, String delimiter, @Nullable
String nullText) {
Review Comment:
Maybe `stream` is more simplify.
```
list.stream()
.map(item -> {
if (item == null) {
return nullText;
} else if (item instanceof String) {
return (String) item;
} else if (item instanceof ByteString) {
return item.toString();
} else {
throw new IllegalStateException(
"arrayToString supports only String or ByteString, but got "
+ item.getClass().getName());
}
}).collect(Collectors.joining(delimiter));
}
```
--
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]