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/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new f9ac302 [docs] add function substring document (#7895)
f9ac302 is described below
commit f9ac30280755392b9b410bef08e0618968a4362c
Author: obobj <[email protected]>
AuthorDate: Fri Jan 28 22:26:11 2022 +0800
[docs] add function substring document (#7895)
---
docs/.vuepress/sidebar/en.js | 1 +
docs/.vuepress/sidebar/zh-CN.js | 1 +
.../sql-functions/string-functions/substring.md | 77 ++++++++++++++++++++++
.../sql-functions/string-functions/substring.md | 72 ++++++++++++++++++++
4 files changed, 151 insertions(+)
diff --git a/docs/.vuepress/sidebar/en.js b/docs/.vuepress/sidebar/en.js
index 726f8f3..a6f1c52 100644
--- a/docs/.vuepress/sidebar/en.js
+++ b/docs/.vuepress/sidebar/en.js
@@ -369,6 +369,7 @@ module.exports = [
"starts_with",
"strleft",
"strright",
+ "substring",
"unhex",
{
title: "fuzzy match",
diff --git a/docs/.vuepress/sidebar/zh-CN.js b/docs/.vuepress/sidebar/zh-CN.js
index ebd0ab8..3f25bcd 100644
--- a/docs/.vuepress/sidebar/zh-CN.js
+++ b/docs/.vuepress/sidebar/zh-CN.js
@@ -373,6 +373,7 @@ module.exports = [
"starts_with",
"strleft",
"strright",
+ "substring",
"unhex",
{
title: "模糊匹配",
diff --git a/docs/en/sql-reference/sql-functions/string-functions/substring.md
b/docs/en/sql-reference/sql-functions/string-functions/substring.md
new file mode 100644
index 0000000..66f7b88
--- /dev/null
+++ b/docs/en/sql-reference/sql-functions/string-functions/substring.md
@@ -0,0 +1,77 @@
+---
+{
+ "title": "substring",
+ "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.
+-->
+
+# substring
+## description
+### Syntax
+
+`VARCHAR substring(VARCHAR str, INT pos[, INT len])`
+
+The forms without a `len` argument return a substring from string `str`
starting at position `pos`.
+The forms with a `len` argument return a substring len characters long from
string `str`, starting at position pos.
+It is also possible to use a negative value for `pos`. In this case,
+the beginning of the substring is `pos` characters from the end of the string,
rather than the beginning.
+A negative value may be used for `pos` in any of the forms of this function.
+A value of 0 for `pos` returns an empty string.
+
+For all forms of SUBSTRING(),
+the position of the first character in the string from which the substring is
to be extracted is reckoned as 1.
+
+If len is less than 1, the result is the empty string.
+## example
+
+```
+mysql> select substring('abc1', -2);
++-----------------------------+
+| substring('abc1', 2) |
++-----------------------------+
+| bc1 |
++-----------------------------+
+
+mysql> select substring('abc1', -2);
++-----------------------------+
+| substring('abc1', -2) |
++-----------------------------+
+| c1 |
++-----------------------------+
+
+mysql> select substring('abc1', 5);
++-----------------------------+
+| substring('abc1', 5) |
++-----------------------------+
+| NULL |
++-----------------------------+
+
+mysql> select substring('abc1def', 2, 2);
++-----------------------------+
+| substring('abc1def', 2, 2) |
++-----------------------------+
+| bc |
++-----------------------------+
+```
+
+## keyword
+SUBSTRING
diff --git
a/docs/zh-CN/sql-reference/sql-functions/string-functions/substring.md
b/docs/zh-CN/sql-reference/sql-functions/string-functions/substring.md
new file mode 100644
index 0000000..cdbbc2b
--- /dev/null
+++ b/docs/zh-CN/sql-reference/sql-functions/string-functions/substring.md
@@ -0,0 +1,72 @@
+---
+{
+ "title": "substring",
+ "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.
+-->
+
+# substring
+## description
+### Syntax
+
+`VARCHAR substring(VARCHAR str, INT pos[, INT len])`
+
+没有 `len` 参数时返回从位置 `pos` 开始的字符串 `str` 的一个子字符串,
+在有 `len` 参数时返回从位置 `pos` 开始的字符串 `str` 的一个长度为 `len` 子字符串,
+`pos` 参数可以使用负值,在这种情况下,子字符串是以字符串 `str` 末尾开始计算 `pos` 个字符,而不是开头,
+`pos` 的值为 0 返回一个空字符串。
+
+对于所有形式的 SUBSTRING(),要从中提取子字符串的字符串中第一个字符的位置为1。
+
+## example
+
+```
+mysql> select substring('abc1', -2);
++-----------------------------+
+| substring('abc1', 2) |
++-----------------------------+
+| bc1 |
++-----------------------------+
+
+mysql> select substring('abc1', -2);
++-----------------------------+
+| substring('abc1', -2) |
++-----------------------------+
+| c1 |
++-----------------------------+
+
+mysql> select substring('abc1', 5);
++-----------------------------+
+| substring('abc1', 5) |
++-----------------------------+
+| NULL |
++-----------------------------+
+
+mysql> select substring('abc1def', 2, 2);
++-----------------------------+
+| substring('abc1def', 2, 2) |
++-----------------------------+
+| bc |
++-----------------------------+
+```
+## keyword
+SUBSTRING
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]