From 94a7431d5a18fc34e3228adc121adb9db709a771 Mon Sep 17 00:00:00 2001
From: lancelly <1435078631@qq.com>
Date: Fri, 24 Mar 2023 19:07:15 +0800
Subject: [PATCH 1/3] doc
---
docs/UserGuide/Operators-Functions/String.md | 48 ++++++++++++++++
.../UserGuide/Operators-Functions/Overview.md | 1 +
.../UserGuide/Operators-Functions/String.md | 56 +++++++++++++++++--
3 files changed, 101 insertions(+), 4 deletions(-)
diff --git a/docs/UserGuide/Operators-Functions/String.md b/docs/UserGuide/Operators-Functions/String.md
index 30d51bf489c4e..9910678a3a44d 100644
--- a/docs/UserGuide/Operators-Functions/String.md
+++ b/docs/UserGuide/Operators-Functions/String.md
@@ -407,6 +407,54 @@ Output series:
+-----------------------------+--------------+----------------------------------------------+
```
+## replace
+
+### Usage
+
+Replace a substring in the input sequence with the target substring.
+
+**Name:** SUBSTRING
+
+**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
### Usage
diff --git a/docs/zh/UserGuide/Operators-Functions/Overview.md b/docs/zh/UserGuide/Operators-Functions/Overview.md
index 257b4587f6306..3f204d6662cfd 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是待拼接的字符串。
`series_behind`: 指定拼接时时间序列是否在后面,默认为`false`。 | TEXT | 拼接字符串和`target`字串 |
| SUBSTRING | TEXT | `from`: 指定子串开始下标
`for`: 指定的字符个数之后停止 | TEXT | 提取字符串的子字符串,从指定的第一个字符开始,并在指定的字符数之后停止。下标从1开始。from 和 for的范围是 INT32 类型取值范围。 |
+| REPLACE | TEXT | 第一个参数: 需要替换的目标子串
第二个参数:要替换成的子串 | 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 f59bcc7abc2b5..496fcfc9f93b8 100644
--- a/docs/zh/UserGuide/Operators-Functions/String.md
+++ b/docs/zh/UserGuide/Operators-Functions/String.md
@@ -411,6 +411,54 @@ select s1, substring(s1 from 1 for 2) from root.sg1.d1
+-----------------------------+--------------+----------------------------------------------+
```
+### 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
From 259560cd06b911ce3649e56c8710982315bbc463 Mon Sep 17 00:00:00 2001
From: lancelly <1435078631@qq.com>
Date: Fri, 24 Mar 2023 19:15:14 +0800
Subject: [PATCH 2/3] doc
---
docs/UserGuide/Operators-Functions/String.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/UserGuide/Operators-Functions/String.md b/docs/UserGuide/Operators-Functions/String.md
index 9910678a3a44d..cf74e578363ac 100644
--- a/docs/UserGuide/Operators-Functions/String.md
+++ b/docs/UserGuide/Operators-Functions/String.md
@@ -413,7 +413,7 @@ Output series:
Replace a substring in the input sequence with the target substring.
-**Name:** SUBSTRING
+**Name:** REPLACE
**Input Series:** Only support a single input series. The data type is TEXT.
From 2f23d335651bdbec5d66494870f5a5c3415cb3e9 Mon Sep 17 00:00:00 2001
From: lancelly <1435078631@qq.com>
Date: Fri, 24 Mar 2023 19:17:52 +0800
Subject: [PATCH 3/3] doc
---
docs/UserGuide/Operators-Functions/String.md | 24 +++++++++----------
.../UserGuide/Operators-Functions/String.md | 24 +++++++++----------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/docs/UserGuide/Operators-Functions/String.md b/docs/UserGuide/Operators-Functions/String.md
index cf74e578363ac..1391071e81743 100644
--- a/docs/UserGuide/Operators-Functions/String.md
+++ b/docs/UserGuide/Operators-Functions/String.md
@@ -399,12 +399,12 @@ 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
@@ -447,12 +447,12 @@ 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|
-+-----------------------------+--------------+----------------------------------------------+
++-----------------------------+--------------+-----------------------------------+
+| 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/String.md b/docs/zh/UserGuide/Operators-Functions/String.md
index 496fcfc9f93b8..c63c6b2afa182 100644
--- a/docs/zh/UserGuide/Operators-Functions/String.md
+++ b/docs/zh/UserGuide/Operators-Functions/String.md
@@ -403,12 +403,12 @@ 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
@@ -451,12 +451,12 @@ 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|
-+-----------------------------+--------------+----------------------------------------------+
++-----------------------------+--------------+-----------------------------------+
+| 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