You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/03/25 08:45:07 UTC

[iotdb] branch master updated: Add user doc for function Replace

This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new aa46413528 Add user doc for function Replace
aa46413528 is described below

commit aa46413528ed135c2ddf0514216c2723807fb49b
Author: Liao Lanyu <14...@qq.com>
AuthorDate: Sat Mar 25 16:44:59 2023 +0800

    Add user doc for function Replace
---
 docs/UserGuide/Operators-Functions/String.md      | 60 ++++++++++++++++++--
 docs/zh/UserGuide/Operators-Functions/Overview.md |  1 +
 docs/zh/UserGuide/Operators-Functions/String.md   | 68 +++++++++++++++++++----
 3 files changed, 113 insertions(+), 16 deletions(-)

diff --git a/docs/UserGuide/Operators-Functions/String.md b/docs/UserGuide/Operators-Functions/String.md
index 30d51bf489..1391071e81 100644
--- a/docs/UserGuide/Operators-Functions/String.md
+++ b/docs/UserGuide/Operators-Functions/String.md
@@ -399,12 +399,60 @@ select s1, substring(s1 from 1 for 2) from root.sg1.d1
 Output series:
 
 ```
-+-----------------------------+--------------+----------------------------------------------+
-|                         Time|root.sg1.d1.s1|SUBSTRING(root.sg1.d1.s1 FROM 1 FOR 2)        |
-+-----------------------------+--------------+----------------------------------------------+
-|1970-01-01T08:00:00.001+08:00|        1test1|                                            1t|
-|1970-01-01T08:00:00.002+08:00|      22test22|                                            22|
-+-----------------------------+--------------+----------------------------------------------+
++-----------------------------+--------------+--------------------------------------+
+|                         Time|root.sg1.d1.s1|SUBSTRING(root.sg1.d1.s1 FROM 1 FOR 2)|
++-----------------------------+--------------+--------------------------------------+
+|1970-01-01T08:00:00.001+08:00|        1test1|                                    1t|
+|1970-01-01T08:00:00.002+08:00|      22test22|                                    22|
++-----------------------------+--------------+--------------------------------------+
+```
+
+## replace
+
+### Usage
+
+Replace a substring in the input sequence with the target substring.
+
+**Name:** REPLACE
+
+**Input Series:** Only support a single input series. The data type is TEXT.
+
+**Parameter:**
++ first parameter: The target substring to be replaced.
++ second parameter: The substring to replace with.
+
+**Output Series:** Output a single series. The type is TEXT.
+
+**Note:** Returns NULL if input is NULL.
+
+### Examples
+
+Input series:
+
+```
++-----------------------------+--------------+
+|                         Time|root.sg1.d1.s1|
++-----------------------------+--------------+
+|1970-01-01T08:00:00.001+08:00|        1test1|
+|1970-01-01T08:00:00.002+08:00|      22test22|
++-----------------------------+--------------+
+```
+
+SQL for query:
+
+```sql
+select s1, replace(s1, 'es', 'tt') from root.sg1.d1
+```
+
+Output series:
+
+```
++-----------------------------+--------------+-----------------------------------+
+|                         Time|root.sg1.d1.s1|REPLACE(root.sg1.d1.s1, 'es', 'tt')|
++-----------------------------+--------------+-----------------------------------+
+|1970-01-01T08:00:00.001+08:00|        1test1|                             1tttt1|
+|1970-01-01T08:00:00.002+08:00|      22test22|                           22tttt22|
++-----------------------------+--------------+-----------------------------------+
 ```
 
 ## Upper
diff --git a/docs/zh/UserGuide/Operators-Functions/Overview.md b/docs/zh/UserGuide/Operators-Functions/Overview.md
index 257b4587f6..3f204d6662 100644
--- a/docs/zh/UserGuide/Operators-Functions/Overview.md
+++ b/docs/zh/UserGuide/Operators-Functions/Overview.md
@@ -159,6 +159,7 @@ OR, |, ||
 | ENDSWITH        | TEXT | `target`: 需要匹配的后缀                                                                                         | BOOLEAN | 判断字符串是否有指定后缀                                                            |
 | CONCAT          | TEXT | `targets`: 一系列 K-V, key需要以`target`为前缀且不重复, value是待拼接的字符串。<br/>`series_behind`: 指定拼接时时间序列是否在后面,默认为`false`。 | TEXT | 拼接字符串和`target`字串                                                        |
 | SUBSTRING       | TEXT | `from`: 指定子串开始下标 <br/>`for`: 指定的字符个数之后停止                                                                  | TEXT | 提取字符串的子字符串,从指定的第一个字符开始,并在指定的字符数之后停止。下标从1开始。from 和 for的范围是 INT32 类型取值范围。 |
+| REPLACE | TEXT | 第一个参数: 需要替换的目标子串<br />第二个参数:要替换成的子串 | TEXT | 将输入序列中的子串替换成目标子串 |
 | UPPER           | TEXT | 无                                                                                                         | TEXT | 将字符串转化为大写                                                               |
 | LOWER           | TEXT | 无                                                                                                         | TEXT | 将字符串转化为小写                                                               |
 | TRIM            | TEXT | 无                                                                                                         | TEXT | 移除字符串前后的空格                                                              |
diff --git a/docs/zh/UserGuide/Operators-Functions/String.md b/docs/zh/UserGuide/Operators-Functions/String.md
index f59bcc7abc..c63c6b2afa 100644
--- a/docs/zh/UserGuide/Operators-Functions/String.md
+++ b/docs/zh/UserGuide/Operators-Functions/String.md
@@ -403,12 +403,60 @@ select s1, substring(s1 from 1 for 2) from root.sg1.d1
 输出序列:
 
 ```
-+-----------------------------+--------------+----------------------------------------------+
-|                         Time|root.sg1.d1.s1|  SUBSTRING(root.sg1.d1.s1 FROM 1 FOR 2)      |
-+-----------------------------+--------------+----------------------------------------------+
-|1970-01-01T08:00:00.001+08:00|        1test1|                                            1t|
-|1970-01-01T08:00:00.002+08:00|      22test22|                                            22|
-+-----------------------------+--------------+----------------------------------------------+
++-----------------------------+--------------+--------------------------------------+
+|                         Time|root.sg1.d1.s1|SUBSTRING(root.sg1.d1.s1 FROM 1 FOR 2)|
++-----------------------------+--------------+--------------------------------------+
+|1970-01-01T08:00:00.001+08:00|        1test1|                                    1t|
+|1970-01-01T08:00:00.002+08:00|      22test22|                                    22|
++-----------------------------+--------------+--------------------------------------+
+```
+
+###  Replace
+
+####  函数简介
+将输入序列中的子串替换成目标子串。
+
+**函数名:** REPLACE
+
+
+**输入序列:** 仅支持单个输入序列,类型为TEXT。
+
+**参数:**
++ 第一个参数: 需要替换的目标子串。
++ 第二个参数: 要替换成的子串。
+
+**输出序列:** 输出单个序列,类型为 TEXT。
+
+**提示:** 如果输入是NULL,返回NULL。
+
+####  使用示例
+
+输入序列:
+
+```
++-----------------------------+--------------+
+|                         Time|root.sg1.d1.s1|
++-----------------------------+--------------+
+|1970-01-01T08:00:00.001+08:00|        1test1|
+|1970-01-01T08:00:00.002+08:00|      22test22|
++-----------------------------+--------------+
+```
+
+用于查询的 SQL 语句:
+
+```sql
+select s1, replace(s1, 'es', 'tt') from root.sg1.d1
+```
+
+输出序列:
+
+```
++-----------------------------+--------------+-----------------------------------+
+|                         Time|root.sg1.d1.s1|REPLACE(root.sg1.d1.s1, 'es', 'tt')|
++-----------------------------+--------------+-----------------------------------+
+|1970-01-01T08:00:00.001+08:00|        1test1|                             1tttt1|
+|1970-01-01T08:00:00.002+08:00|      22test22|                           22tttt22|
++-----------------------------+--------------+-----------------------------------+
 ```
 
 ###  Upper
@@ -591,7 +639,7 @@ select s1, s2, strcmp(s1, s2) from root.sg1.d1
 
 ####  函数简介
 
-**非内置函数,需要注册数据质量函数库后才能使用。**本函数用于将文本中的子串替换为指定的字符串。
+**非内置函数,需要注册数据质量函数库后才能使用**。本函数用于将文本中的子串替换为指定的字符串。
 
 **函数名:** STRREPLACE
 
@@ -669,7 +717,7 @@ select strreplace(s1, "target"=",", "replace"="/", "limit"="1", "offset"="1", "r
 
 ####  函数简介
 
-**非内置函数,需要注册数据质量函数库后才能使用。**本函数用于正则表达式匹配文本中的具体内容并返回。
+**非内置函数,需要注册数据质量函数库后才能使用**。本函数用于正则表达式匹配文本中的具体内容并返回。
 
 **函数名:** REGEXMATCH
 
@@ -726,7 +774,7 @@ select regexmatch(s1, "regex"="\d+\.\d+\.\d+\.\d+", "group"="0") from root.test.
 
 ####  函数简介
 
-**非内置函数,需要注册数据质量函数库后才能使用。**本函数用于将文本中符合正则表达式的匹配结果替换为指定的字符串。
+**非内置函数,需要注册数据质量函数库后才能使用**。本函数用于将文本中符合正则表达式的匹配结果替换为指定的字符串。
 
 **函数名:** REGEXREPLACE
 
@@ -784,7 +832,7 @@ select regexreplace(s1, "regex"="192\.168\.0\.(\d+)", "replace"="cluster-$1", "l
 
 ####  函数简介
 
-**非内置函数,需要注册数据质量函数库后才能使用。**本函数用于使用给定的正则表达式切分文本,并返回指定的项。
+**非内置函数,需要注册数据质量函数库后才能使用**。本函数用于使用给定的正则表达式切分文本,并返回指定的项。
 
 **函数名:** REGEXSPLIT