[GitHub] yanghua commented on a change in pull request #6450: [FLINK-9991] Add regex_replace supported in TableAPI and SQL

2018-07-29 Thread GitBox
yanghua commented on a change in pull request #6450: [FLINK-9991] Add 
regex_replace supported in TableAPI and SQL
URL: https://github.com/apache/flink/pull/6450#discussion_r205991262
 
 

 ##
 File path: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala
 ##
 @@ -450,6 +450,39 @@ class ScalarFunctionsTest extends ScalarTypesTestBase {
   "")
   }
 
+  @Test
+  def testRegexReplace(): Unit = {
+testAllApis(
+  "foobar".regexReplace("oo|ar", ""),
+  "'foobar'.regexReplace('oo|ar', '')",
+  "regex_replace('foobar', 'oo|ar', '')",
+  "fb")
+
+testAllApis(
+  "foobar".regexReplace("oo|ar", "abc"),
+  "'foobar'.regexReplace('oo|ar', 'abc')",
+  "regex_replace('foobar', 'oo|ar', 'abc')",
+  "fabcbabc")
+
+testAllApis(
+  'f33.regexReplace("oo|ar", ""),
+  "f33.regexReplace('oo|ar', '')",
+  "REGEX_REPLACE(f33, 'oo|ar', '')",
+  "null")
+
+testAllApis(
+  "foobar".regexReplace('f33, ""),
+  "'foobar'.regexReplace(f33, '')",
+  "REGEX_REPLACE('foobar', f33, '')",
+  "null")
+
+testAllApis(
+  "foobar".regexReplace("oo|ar", 'f33),
+  "'foobar'.regexReplace('oo|ar', f33)",
+  "REGEX_REPLACE('foobar', 'oo|ar', f33)",
+  "null")
+  }
+
 
 Review comment:
   Accepted this test case. It should return 'for', the result based on the 
regular expression.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] yanghua commented on a change in pull request #6450: [FLINK-9991] Add regex_replace supported in TableAPI and SQL

2018-07-29 Thread GitBox
yanghua commented on a change in pull request #6450: [FLINK-9991] Add 
regex_replace supported in TableAPI and SQL
URL: https://github.com/apache/flink/pull/6450#discussion_r205990913
 
 

 ##
 File path: docs/dev/table/tableApi.md
 ##
 @@ -4025,6 +4038,18 @@ STRING.initCap()
   
 
 
+
+  
+{% highlight scala %}
+STRING.regexReplace(regex STRING, replacement STRING)
+{% endhighlight %}
+  
+
+  
+Returns the string resulting from replacing all substrings that 
match the regex with replacement, if string or regex or replacement is NULL, 
returns NULL. E.g. "foobar".regexReplace("oo|ar", "") returns "fb".
+  
+
+
 
 Review comment:
   No, it's scala doc.


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:
us...@infra.apache.org


With regards,
Apache Git Services