Guibo-Pan commented on a change in pull request #6576: [FLINK-10145][table] Add 
replace supported in TableAPI and SQL
URL: https://github.com/apache/flink/pull/6576#discussion_r211477186
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
 ##########
 @@ -92,6 +92,17 @@ object ScalarFunctions {
     sb.toString
   }
 
+  /**
+    * Returns the string str with all non-overlapping occurrences
+    * of search replaced with replacement.
+    */
+  def replace(str: String, search: String, replacement: String): String = {
 
 Review comment:
   The same reason like the above. The calcite builtin `replace` can not handle 
null parameters, which may throw NPE. 
   The builtin `replace` is
   ```
   public static String replace(String s, String search, String replacement) {
       return s.replace(search, replacement);
     }
   ```
   and in java.lang.String#replace it is
   ```
   public String replace(CharSequence target, CharSequence replacement) {
           return Pattern.compile(target.toString(), Pattern.LITERAL).matcher(
                   
this).replaceAll(Matcher.quoteReplacement(replacement.toString()));
       }
   ```
   Here it calls `toString` method, that will cause Exception when any of the 
thress params is `null`.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to