zzzzzzzs commented on code in PR #20342:
URL: https://github.com/apache/flink/pull/20342#discussion_r1154393863
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java:
##########
@@ -371,6 +371,11 @@ public static String repeat(String str, int repeat) {
return EncodingUtils.repeat(str, repeat);
}
+ /** Returns an expr where all characters in from have been replaced with
those in to. */
+ public static String translate3(String str, String search, String
replacement) {
+ return org.apache.commons.lang3.StringUtils.replaceChars(str, search,
replacement);
Review Comment:
StringUtils#replaceChars replaces a set of characters with a single
character, while SqlFunctionUtils#replace replaces a substring with another
string.
example:
``` java
String replaced = StringUtils.replaceChars("AaBbCc", "abc", "123");
System.out.println(replaced); // "A1B2C3"
String replaced = SqlFunctionUtils.replace("AaBbCc", "abc", "123");
System.out.println(replaced1); // "AaBbCc"
```
To meet the functionality requirements of Hive or Spark, it is necessary to
use StringUtils#replaceChars. This is also the approach taken in Calcite.
--
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]