Skip to content

Commit

Permalink
[FLINK-10145][table] Add replace supported in TableAPI and SQL
Browse files Browse the repository at this point in the history
Change-Id: Ibeb0e1bf2cc68bb3cfeb6ab7c1f7d791096d017b
  • Loading branch information
Guibo-Pan committed Sep 26, 2018
1 parent 861fa80 commit 1f6b375
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
18 changes: 9 additions & 9 deletions docs/dev/table/functions.md
Expand Up @@ -2451,12 +2451,12 @@ SUBSTRING(string FROM integer1 [ FOR integer2 ])
<tr>
<td>
{% highlight text %}
REPLACE(string, search, replacement)
REPLACE(string1, string2, string3)
{% endhighlight %}
</td>
<td>
<p>Returns a new string from <i>string</i> replaced <i>search</i>(non-overlapping) with <i>replacement</i>.</p>
<p>E.g., <code>REPLACE("hello world", "world", "flink")</code> returns "hello flink"; <code>REPLACE("ababab", "abab", "z")</code> returns "zab"</p>
<p>Returns a new string which replaces <i>string2</i> with <i>string3</i> (non-overlapping) from <i>string1</i></p>
<p>E.g., <code>REPLACE("hello world", "world", "flink")</code> returns "hello flink"; <code>REPLACE("ababab", "abab", "z")</code> returns "zab".</p>
</td>
</tr>

Expand Down Expand Up @@ -2703,12 +2703,12 @@ STRING.substring(INT1, INT2)
<tr>
<td>
{% highlight java %}
STRING.replace(STRING1, STRING2)
STRING1.replace(STRING2, STRING3)
{% endhighlight %}
</td>
<td>
<p>Returns a new string from <i>STRING</i> replaced <i>STRING1</i>(non-overlapping) with <i>STRING2</i>.</p>
<p>E.g., <code>"hello world".replace("world", "flink")</code> returns "hello flink"; <code>"ababab".replace("abab", "z")</code> returns "zab"</p>
<p>Returns a new string which replaces <i>STRING2</i> with <i>STRING3</i> (non-overlapping) from <i>STRING1</i>.</p>
<p>E.g., <code>'hello world'.replace('world', 'flink')</code> returns 'hello flink'; <code>'ababab'.replace('abab', 'z')</code> returns 'zab'.</p>
</td>
</tr>

Expand Down Expand Up @@ -2954,12 +2954,12 @@ STRING.substring(INT1, INT2)
<tr>
<td>
{% highlight scala %}
STRING.replace(STRING1, STRING2)
STRING1.replace(STRING2, STRING3)
{% endhighlight %}
</td>
<td>
<p>Returns a new string from <i>STRING</i> replaced <i>STRING1</i>(non-overlapping) with <i>STRING2</i>.</p>
<p>E.g., <code>"hello world".replace("world", "flink")</code> returns "hello flink"; <code>"ababab".replace("abab", "z")</code> returns "zab"</p>
<p>Returns a new string which replaces <i>STRING2</i> with <i>STRING3</i> (non-overlapping) from <i>STRING1</i>.</p>
<p>E.g., <code>"hello world".replace("world", "flink")</code> returns "hello flink"; <code>"ababab".replace("abab", "z")</code> returns "zab".</p>
</td>
</tr>

Expand Down
Expand Up @@ -67,7 +67,6 @@ object ScalarSqlFunctions {
OperandTypes.ONE_OR_MORE,
SqlFunctionCategory.STRING)


val LOG = new SqlFunction(
"LOG",
SqlKind.OTHER_FUNCTION,
Expand Down
Expand Up @@ -95,17 +95,6 @@ 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 = {
if (str == null || search == null || replacement == null) {
return null
}
str.replace(search, replacement)
}

/**
* Returns the natural logarithm of "x".
*/
Expand Down

0 comments on commit 1f6b375

Please sign in to comment.