This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new 9e634028ac [function] add replace_empty function doc (#749)
9e634028ac is described below
commit 9e634028ac8888b2ed05e9ce8d587542fb56bf84
Author: Mingyu Chen <[email protected]>
AuthorDate: Thu Jun 20 14:09:00 2024 +0800
[function] add replace_empty function doc (#749)
---
.../string-functions/replace_empty.md | 70 ++++++++++++++++++++++
.../string-functions/replace_empty.md | 70 ++++++++++++++++++++++
.../string-functions/replace_empty.md | 70 ++++++++++++++++++++++
sidebars.json | 1 +
.../string-functions/replace_empty.md | 70 ++++++++++++++++++++++
versioned_sidebars/version-2.1-sidebars.json | 3 +-
6 files changed, 283 insertions(+), 1 deletion(-)
diff --git a/docs/sql-manual/sql-functions/string-functions/replace_empty.md
b/docs/sql-manual/sql-functions/string-functions/replace_empty.md
new file mode 100644
index 0000000000..51fbc38cee
--- /dev/null
+++ b/docs/sql-manual/sql-functions/string-functions/replace_empty.md
@@ -0,0 +1,70 @@
+---
+{
+ "title": "REPLACE_EMPTY",
+ "language": "en"
+}
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## replace_empty
+### description
+#### Syntax
+
+Since 2.1.5
+
+`VARCHAR REPLACE_EMPTY (VARCHAR str, VARCHAR old, VARCHAR new)`
+
+Replace all `old` substrings in `str` string with `new` string.
+
+Unlike the `REPLACE()` function, when `old` is an empty string, the `new`
string is inserted before each character of the `str` string and at the end of
the `str` string.
+
+Other than that, the other behaviors are exactly the same as the `REPLACE()`
function.
+
+This function is mainly used for compatibility with Presto and Trino, and its
behavior is exactly the same as the `REPLACE()` function in Presto and Trino.
+
+### example
+
+```
+mysql> select replace_empty("http://www.baidu.com:9090", "9090", "");
++------------------------------------------------------+
+| replace('http://www.baidu.com:9090', '9090', '') |
++------------------------------------------------------+
+| http://www.baidu.com: |
++------------------------------------------------------+
+
+mysql> select replace_empty("abc", '', 'xyz');
++---------------------------------+
+| replace_empty('abc', '', 'xyz') |
++---------------------------------+
+| xyzaxyzbxyzcxyz |
++---------------------------------+
+
+mysql> select replace_empty("", "", "xyz");
++------------------------------+
+| replace_empty('', '', 'xyz') |
++------------------------------+
+| xyz |
++------------------------------+
+```
+
+### keywords
+
+ REPLACE_EMPTY
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/string-functions/replace_empty.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/string-functions/replace_empty.md
new file mode 100644
index 0000000000..20a5585884
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/string-functions/replace_empty.md
@@ -0,0 +1,70 @@
+---
+{
+ "title": "REPLACE_EMPTY",
+ "language": "zh-CN"
+}
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## replace_empty
+### description
+#### Syntax
+
+自 2.1.5 版本支持。
+
+`VARCHAR REPLACE_EMPTY (VARCHAR str, VARCHAR old, VARCHAR new)`
+
+将 `str` 字符串中的 `old` 子串全部替换为 `new` 字符串。
+
+和 `REPLACE()` 函数不同的是,当 `old` 为空字符串时,会将 `new` 字符串插入到 `str` 字符串的每个字符前,以及 `str`
字符串的最后。
+
+除此之外,其他行为和 `REPLACE()` 函数完全一致。
+
+该函数主要用于兼容 Presto、Trino,其行为了 Presto、Trino 中的 `REPLACE()` 函数完全一致。
+
+### example
+
+```
+mysql> select replace_empty("http://www.baidu.com:9090", "9090", "");
++------------------------------------------------------+
+| replace('http://www.baidu.com:9090', '9090', '') |
++------------------------------------------------------+
+| http://www.baidu.com: |
++------------------------------------------------------+
+
+mysql> select replace_empty("abc", '', 'xyz');
++---------------------------------+
+| replace_empty('abc', '', 'xyz') |
++---------------------------------+
+| xyzaxyzbxyzcxyz |
++---------------------------------+
+
+mysql> select replace_empty("", "", "xyz");
++------------------------------+
+| replace_empty('', '', 'xyz') |
++------------------------------+
+| xyz |
++------------------------------+
+```
+
+### keywords
+
+ REPLACE_EMPTY
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/string-functions/replace_empty.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/string-functions/replace_empty.md
new file mode 100644
index 0000000000..20a5585884
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/string-functions/replace_empty.md
@@ -0,0 +1,70 @@
+---
+{
+ "title": "REPLACE_EMPTY",
+ "language": "zh-CN"
+}
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## replace_empty
+### description
+#### Syntax
+
+自 2.1.5 版本支持。
+
+`VARCHAR REPLACE_EMPTY (VARCHAR str, VARCHAR old, VARCHAR new)`
+
+将 `str` 字符串中的 `old` 子串全部替换为 `new` 字符串。
+
+和 `REPLACE()` 函数不同的是,当 `old` 为空字符串时,会将 `new` 字符串插入到 `str` 字符串的每个字符前,以及 `str`
字符串的最后。
+
+除此之外,其他行为和 `REPLACE()` 函数完全一致。
+
+该函数主要用于兼容 Presto、Trino,其行为了 Presto、Trino 中的 `REPLACE()` 函数完全一致。
+
+### example
+
+```
+mysql> select replace_empty("http://www.baidu.com:9090", "9090", "");
++------------------------------------------------------+
+| replace('http://www.baidu.com:9090', '9090', '') |
++------------------------------------------------------+
+| http://www.baidu.com: |
++------------------------------------------------------+
+
+mysql> select replace_empty("abc", '', 'xyz');
++---------------------------------+
+| replace_empty('abc', '', 'xyz') |
++---------------------------------+
+| xyzaxyzbxyzcxyz |
++---------------------------------+
+
+mysql> select replace_empty("", "", "xyz");
++------------------------------+
+| replace_empty('', '', 'xyz') |
++------------------------------+
+| xyz |
++------------------------------+
+```
+
+### keywords
+
+ REPLACE_EMPTY
diff --git a/sidebars.json b/sidebars.json
index ba37daf356..721f2ff735 100644
--- a/sidebars.json
+++ b/sidebars.json
@@ -731,6 +731,7 @@
"sql-manual/sql-functions/string-functions/field",
"sql-manual/sql-functions/string-functions/find-in-set",
"sql-manual/sql-functions/string-functions/replace",
+
"sql-manual/sql-functions/string-functions/replace_empty",
"sql-manual/sql-functions/string-functions/strleft",
"sql-manual/sql-functions/string-functions/strright",
"sql-manual/sql-functions/string-functions/split-part",
diff --git
a/versioned_docs/version-2.1/sql-manual/sql-functions/string-functions/replace_empty.md
b/versioned_docs/version-2.1/sql-manual/sql-functions/string-functions/replace_empty.md
new file mode 100644
index 0000000000..51fbc38cee
--- /dev/null
+++
b/versioned_docs/version-2.1/sql-manual/sql-functions/string-functions/replace_empty.md
@@ -0,0 +1,70 @@
+---
+{
+ "title": "REPLACE_EMPTY",
+ "language": "en"
+}
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+## replace_empty
+### description
+#### Syntax
+
+Since 2.1.5
+
+`VARCHAR REPLACE_EMPTY (VARCHAR str, VARCHAR old, VARCHAR new)`
+
+Replace all `old` substrings in `str` string with `new` string.
+
+Unlike the `REPLACE()` function, when `old` is an empty string, the `new`
string is inserted before each character of the `str` string and at the end of
the `str` string.
+
+Other than that, the other behaviors are exactly the same as the `REPLACE()`
function.
+
+This function is mainly used for compatibility with Presto and Trino, and its
behavior is exactly the same as the `REPLACE()` function in Presto and Trino.
+
+### example
+
+```
+mysql> select replace_empty("http://www.baidu.com:9090", "9090", "");
++------------------------------------------------------+
+| replace('http://www.baidu.com:9090', '9090', '') |
++------------------------------------------------------+
+| http://www.baidu.com: |
++------------------------------------------------------+
+
+mysql> select replace_empty("abc", '', 'xyz');
++---------------------------------+
+| replace_empty('abc', '', 'xyz') |
++---------------------------------+
+| xyzaxyzbxyzcxyz |
++---------------------------------+
+
+mysql> select replace_empty("", "", "xyz");
++------------------------------+
+| replace_empty('', '', 'xyz') |
++------------------------------+
+| xyz |
++------------------------------+
+```
+
+### keywords
+
+ REPLACE_EMPTY
diff --git a/versioned_sidebars/version-2.1-sidebars.json
b/versioned_sidebars/version-2.1-sidebars.json
index 2a6d9b98bb..1ba45d7587 100644
--- a/versioned_sidebars/version-2.1-sidebars.json
+++ b/versioned_sidebars/version-2.1-sidebars.json
@@ -718,6 +718,7 @@
"sql-manual/sql-functions/string-functions/field",
"sql-manual/sql-functions/string-functions/find-in-set",
"sql-manual/sql-functions/string-functions/replace",
+
"sql-manual/sql-functions/string-functions/replace_empty",
"sql-manual/sql-functions/string-functions/strleft",
"sql-manual/sql-functions/string-functions/strright",
"sql-manual/sql-functions/string-functions/split-part",
@@ -1490,4 +1491,4 @@
]
}
]
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]