[ 
https://issues.apache.org/jira/browse/FLINK-9991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16561287#comment-16561287
 ] 

ASF GitHub Bot commented on FLINK-9991:
---------------------------------------

TisonKun 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_r205989801
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarFunctionsTest.scala
 ##########
 @@ -450,6 +450,39 @@ class ScalarFunctionsTest extends ScalarTypesTestBase {
       "1111111111111111111111111111111111111111111111111111111111111111")
   }
 
+  @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:
   what about `"fooor".regexReplace("oo", "")`? is it `"for"` or `"fr"`? the 
problem is what about the complicated/corner case, which maybe worth a test to 
cover it.

----------------------------------------------------------------
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


> Add regex_replace supported in TableAPI and SQL
> -----------------------------------------------
>
>                 Key: FLINK-9991
>                 URL: https://issues.apache.org/jira/browse/FLINK-9991
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API & SQL
>            Reporter: vinoyang
>            Assignee: vinoyang
>            Priority: Minor
>              Labels: pull-request-available
>
> regexp_replace is a very userful function to process String. 
>  For example :
> {code:java}
> regexp_replace("foobar", "oo|ar", "") //returns 'fb.'
> {code}
> It is supported as a UDF in Hive, more details please see[1].
> [1]: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to