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

zclll 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 77976198fad [doc](function)doc for count-substring (#2761)
77976198fad is described below

commit 77976198fadaae34e998b48f722a0a7e87fbab4b
Author: Mryange <[email protected]>
AuthorDate: Tue Aug 26 16:52:53 2025 +0800

    [doc](function)doc for count-substring (#2761)
    
    ## Versions
    
    - [x] dev
    - [ ] 3.0
    - [ ] 2.1
    - [ ] 2.0
    
    ## Languages
    
    - [x] Chinese
    - [x] English
    
    ## Docs Checklist
    
    - [ ] Checked by AI
    - [ ] Test Cases Built
---
 .../string-functions/count_substrings.md           | 38 +++++++++++++++++++---
 .../string-functions/count_substrings.md           | 38 +++++++++++++++++++---
 2 files changed, 66 insertions(+), 10 deletions(-)

diff --git 
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/count_substrings.md
 
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/count_substrings.md
index 07904f0f7ac..77cac5fecd4 100644
--- 
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/count_substrings.md
+++ 
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/count_substrings.md
@@ -12,14 +12,15 @@ The COUNT_SUBSTRINGS function counts the number of 
occurrences of a specified su
 ## Syntax
 
 ```sql
-COUNT_SUBSTRINGS(<str>, <pattern>)
+COUNT_SUBSTRINGS(<str>, <pattern>[, <start_pos>])
 ```
 
 ## Parameters
-| Parameter | Description                             |
-| --------- | --------------------------------------- |
-| `<str>` | The string to be searched. Type: STRING |
-| `<pattern>` | The substring to match. Type: STRING    |
+| Parameter     | Description                                                  
      |
+| ------------- | 
------------------------------------------------------------------ |
+| `<str>`       | The string to be searched. Type: STRING                      
      |
+| `<pattern>`   | The substring to match. Type: STRING                         
      |
+| `<start_pos>` | Position (1-based) at which the search starts. Type: INT. 
Optional |
 
 ## Return Value
 
@@ -29,6 +30,7 @@ Special cases:
 - If str is NULL, returns NULL
 - If pattern is an empty string, returns 0
 - If str is an empty string, returns 0
+- If start_pos is less than or equal to 0 or exceeds the string length, 
returns 0
 
 ## Examples
 
@@ -90,4 +92,30 @@ SELECT count_substrings('a,b,c,abcde', '');
 +-------------------------------------+
 |                                   0 |
 +-------------------------------------+
+```
+
+6. Using the start position parameter
+```sql
+SELECT count_substrings('你好,世界!你好,世界!', '世界', 1), 
+       count_substrings('你好,世界!你好,世界!', '世界', 6);
+```
+```text
++-----------------------------------------------------------------------+-----------------------------------------------------------------------+
+| count_substrings('你好,世界!你好,世界!', '世界', 1)               | 
count_substrings('你好,世界!你好,世界!', '世界', 6)               |
++-----------------------------------------------------------------------+-----------------------------------------------------------------------+
+|                                                                     2 |      
                                                               1 |
++-----------------------------------------------------------------------+-----------------------------------------------------------------------+
+```
+
+7. Start position out of range
+```sql
+SELECT count_substrings('你好,世界!你好,世界!', '世界', 0), 
+       count_substrings('你好,世界!你好,世界!', '世界', 30);
+```
+```text
++-----------------------------------------------------------------------+------------------------------------------------------------------------+
+| count_substrings('你好,世界!你好,世界!', '世界', 0)               | 
count_substrings('你好,世界!你好,世界!', '世界', 30)               |
++-----------------------------------------------------------------------+------------------------------------------------------------------------+
+|                                                                     0 |      
                                                                0 |
++-----------------------------------------------------------------------+------------------------------------------------------------------------+
 ```
\ No newline at end of file
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/count_substrings.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/count_substrings.md
index 6db5a709e7e..f8c4de3ab3f 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/count_substrings.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/count_substrings.md
@@ -12,14 +12,15 @@ COUNT_SUBSTRINGS 函数用于计算一个字符串中指定子串出现的次数
 ## 语法
 
 ```sql
-COUNT_SUBSTRINGS(<str>, <pattern>)
+COUNT_SUBSTRINGS(<str>, <pattern>[, <start_pos>])
 ```
 
 ## 参数
-| 参数    | 说明                           |
-| ------- | ------------------------------ |
-| `<str>`     | 需要检测的字符串。类型:STRING |
-| `<pattern>` | 需要匹配的子串。类型:STRING   |
+| 参数          | 说明                                               |
+| ------------- | -------------------------------------------------- |
+| `<str>`       | 需要检测的字符串。类型:STRING                     |
+| `<pattern>`   | 需要匹配的子串。类型:STRING                       |
+| `<start_pos>` | 开始搜索的位置(从1开始计数)。类型:INT。可选参数 |
 
 ## 返回值
 
@@ -29,6 +30,7 @@ COUNT_SUBSTRINGS(<str>, <pattern>)
 - 如果 str 为 NULL,返回 NULL
 - 如果 pattern 为空字符串,返回 0
 - 如果 str 为空字符串,返回 0
+- 如果 start_pos 小于等于0或超出字符串长度范围,返回 0
 
 ## 示例
 
@@ -91,3 +93,29 @@ SELECT count_substrings('a,b,c,abcde', '');
 |                                   0 |
 +-------------------------------------+
 ```
+
+6. 使用起始位置参数
+```sql
+SELECT count_substrings('你好,世界!你好,世界!', '世界', 1), 
+       count_substrings('你好,世界!你好,世界!', '世界', 6);
+```
+```text
++-----------------------------------------------------------------------+-----------------------------------------------------------------------+
+| count_substrings('你好,世界!你好,世界!', '世界', 1)               | 
count_substrings('你好,世界!你好,世界!', '世界', 6)               |
++-----------------------------------------------------------------------+-----------------------------------------------------------------------+
+|                                                                     2 |      
                                                               1 |
++-----------------------------------------------------------------------+-----------------------------------------------------------------------+
+```
+
+7. 起始位置超出范围
+```sql
+SELECT count_substrings('你好,世界!你好,世界!', '世界', 0), 
+       count_substrings('你好,世界!你好,世界!', '世界', 30);
+```
+```text
++-----------------------------------------------------------------------+------------------------------------------------------------------------+
+| count_substrings('你好,世界!你好,世界!', '世界', 0)               | 
count_substrings('你好,世界!你好,世界!', '世界', 30)               |
++-----------------------------------------------------------------------+------------------------------------------------------------------------+
+|                                                                     0 |      
                                                                0 |
++-----------------------------------------------------------------------+------------------------------------------------------------------------+
+```


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to