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 304e8ea1793 [fix](doc) dev: backport 4.x string-function example
expansions and corner-case adds (en+zh) (#3848)
304e8ea1793 is described below
commit 304e8ea1793bd15824d716b6c7a8fbdd33e1ffb0
Author: boluor <[email protected]>
AuthorDate: Fri May 29 19:59:40 2026 -0700
[fix](doc) dev: backport 4.x string-function example expansions and
corner-case adds (en+zh) (#3848)
## Summary
Mechanical port of the 4.x fixes in #3833, #3837, #3838, #3839 to
dev/master. Verified against today's master build (selectdb-qa-test
tarball).
**Skipped** (already applied on dev):
- strleft.md ZH dedup (#3837)
- milliseconds-add.md EN BIGINT-range example (#3834 EN-side; the ZH
duplicate-removal piece is in the sibling PR)
## Files (13)
### EN string-functions
- **from-base64.md, instr.md, length.md, locate.md, lpad.md** — backport
corner-case examples (NULL / empty / multi-byte UTF-8 / numeric / etc.)
added in #3833
- **rtrim.md** — add the LENGTH-based 'default-only-strips-ASCII-space'
example (#3837)
- **substring.md** — add the missing 'empty source string' example +
'NULL passed directly' (#3839)
- **trim.md** — replace example 2's prose + expected output
(`trim('ababccaab', 'ab')` is `cca`, not `ababcca` — trim repeatedly
strips from both ends), plus the UTF-8 multi-byte-pattern example
(#3839)
### EN other-functions
- **field.md** — full replace with 4.x post-fix version: adds CREATE
TABLE setup for `baseall` and `class_test` (which the page references
but never created), adds a NULL row to `class_test`, adds DESC and NULLS
FIRST examples that exercise NULL handling (#3789 + #3839 combined)
### ZH
- **field.md** — add the simple `SELECT FIELD(2, 3, 1, 2, 5)` example
(#3839)
- **ltrim.md** — rewrite example 3 with correct expected output; LTRIM
strips ASCII space only, NOT `\t`/`\n`, so the result still contains the
tab/newline. Switched to a LENGTH() comparison for clarity (#3838)
- **substring.md** — add the SUBSTR alias example (#3839)
- **trim.md** — add three examples (no-match returns original; repeated
pattern strips until exhausted; asymmetric removal with multi-char
pattern). Also drop a trailing `;;` typo (#3839)
## Verification
Verified end-to-end against today's master cluster — all added /
modified examples behave identically on master as on 4.1.1, so the doc
fixes apply unchanged.
## Related 4.x PRs
#3833 #3837 #3838 #3839 (and #3789 for the field.md setup blocks).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
---
.../scalar-functions/other-functions/field.md | 65 +++++++++++++++++
.../string-functions/from-base64.md | 60 ++++++++++++++++
.../scalar-functions/string-functions/instr.md | 72 +++++++++++++++++++
.../scalar-functions/string-functions/length.md | 72 +++++++++++++++++++
.../scalar-functions/string-functions/locate.md | 84 ++++++++++++++++++++++
.../scalar-functions/string-functions/lpad.md | 72 +++++++++++++++++++
.../scalar-functions/string-functions/rtrim.md | 24 +++++--
.../scalar-functions/string-functions/substring.md | 24 +++++++
.../scalar-functions/string-functions/trim.md | 24 +++++--
.../scalar-functions/other-functions/field.md | 14 ++++
.../scalar-functions/string-functions/ltrim.md | 14 ++--
.../scalar-functions/string-functions/substring.md | 12 ++++
.../scalar-functions/string-functions/trim.md | 38 +++++++++-
13 files changed, 555 insertions(+), 20 deletions(-)
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/other-functions/field.md
b/docs/sql-manual/sql-functions/scalar-functions/other-functions/field.md
index d7b5b3cc0fc..2dd9ebe5985 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/other-functions/field.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/other-functions/field.md
@@ -32,6 +32,28 @@ FIELD(<expr>, <param> [, ...])
## Examples
+```sql
+-- setup
+CREATE TABLE baseall (k1 INT, k7 VARCHAR(64))
+DISTRIBUTED BY HASH(k1) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO baseall VALUES
+ (1, 'wangjing04'),
+ (2, 'wangyu14'),
+ (3, 'yuanyuan06');
+
+CREATE TABLE class_test (class_name VARCHAR(64))
+DISTRIBUTED BY HASH(class_name) BUCKETS 1
+PROPERTIES ("replication_num" = "1");
+
+INSERT INTO class_test VALUES
+ ('Suzi'), ('Suzi'),
+ ('Ben'), ('Ben'),
+ ('Henry'), ('Henry'),
+ (NULL);
+```
+
```sql
SELECT FIELD(2, 3, 1, 2, 5);
```
@@ -58,6 +80,8 @@ SELECT k1, k7 FROM baseall WHERE k1 IN (1,2,3) ORDER BY
FIELD(k1, 2, 1, 3);
+------+------------+
```
+Custom string ordering. `FIELD` returns `0` for values not in the list —
including `NULL`, which is why the `NULL` row sorts to the top in the ascending
default:
+
```sql
SELECT class_name FROM class_test ORDER BY FIELD(class_name, 'Suzi', 'Ben',
'Henry');
```
@@ -66,6 +90,47 @@ SELECT class_name FROM class_test ORDER BY FIELD(class_name,
'Suzi', 'Ben', 'Hen
+------------+
| class_name |
+------------+
+| NULL |
+| Suzi |
+| Suzi |
+| Ben |
+| Ben |
+| Henry |
+| Henry |
++------------+
+```
+
+Descending — `NULL` (FIELD = 0) is now last:
+
+```sql
+SELECT class_name FROM class_test ORDER BY FIELD(class_name, 'Suzi', 'Ben',
'Henry') DESC;
+```
+
+```text
++------------+
+| class_name |
++------------+
+| Henry |
+| Henry |
+| Ben |
+| Ben |
+| Suzi |
+| Suzi |
+| NULL |
++------------+
+```
+
+You can also use `NULLS FIRST` / `NULLS LAST` to control `NULL` placement
independently of the sort direction:
+
+```sql
+SELECT class_name FROM class_test ORDER BY FIELD(class_name, 'Suzi', 'Ben',
'Henry') NULLS FIRST;
+```
+
+```text
++------------+
+| class_name |
++------------+
+| NULL |
| Suzi |
| Suzi |
| Ben |
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/from-base64.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/from-base64.md
index f82627cab91..c5def5b9477 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/from-base64.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/from-base64.md
@@ -99,4 +99,64 @@ SELECT FROM_BASE64('!!!'), FROM_BASE64('ABC@DEF');
+--------------------+------------------------+
| NULL | NULL |
+--------------------+------------------------+
+```
+
+6. Longer payloads
+```sql
+SELECT FROM_BASE64('SGVsbG8gV29ybGQ='),
FROM_BASE64('VGhlIHF1aWNrIGJyb3duIGZveA==');
+```
+```text
++---------------------------------+---------------------------------------------+
+| FROM_BASE64('SGVsbG8gV29ybGQ=') |
FROM_BASE64('VGhlIHF1aWNrIGJyb3duIGZveA==') |
++---------------------------------+---------------------------------------------+
+| Hello World | The quick brown fox
|
++---------------------------------+---------------------------------------------+
+```
+
+7. UTF-8 multi-byte payloads
+```sql
+SELECT FROM_BASE64('4bmt4bmbw6w='), FROM_BASE64('4biN4biNdW1haSBoZWxsbw==');
+```
+```text
++-----------------------------+-----------------------------------------+
+| FROM_BASE64('4bmt4bmbw6w=') | FROM_BASE64('4biN4biNdW1haSBoZWxsbw==') |
++-----------------------------+-----------------------------------------+
+| ṭṛì | ḍḍumai hello |
++-----------------------------+-----------------------------------------+
+```
+
+8. Email addresses
+```sql
+SELECT FROM_BASE64('dXNlckBleGFtcGxlLmNvbQ=='),
FROM_BASE64('YWRtaW4udGVzdEBjb21wYW55Lm9yZw==');
+```
+```text
++-----------------------------------------+-------------------------------------------------+
+| FROM_BASE64('dXNlckBleGFtcGxlLmNvbQ==') |
FROM_BASE64('YWRtaW4udGVzdEBjb21wYW55Lm9yZw==') |
++-----------------------------------------+-------------------------------------------------+
+| [email protected] | [email protected]
|
++-----------------------------------------+-------------------------------------------------+
+```
+
+9. JSON payloads
+```sql
+SELECT FROM_BASE64('eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9'),
FROM_BASE64('WzEsMiwzLDQsNV0=');
+```
+```text
++-------------------------------------------------+---------------------------------+
+| FROM_BASE64('eyJuYW1lIjoiSm9obiIsImFnZSI6MzB9') |
FROM_BASE64('WzEsMiwzLDQsNV0=') |
++-------------------------------------------------+---------------------------------+
+| {"name":"John","age":30} | [1,2,3,4,5]
|
++-------------------------------------------------+---------------------------------+
+```
+
+10. Round-trip with `TO_BASE64`
+```sql
+SELECT FROM_BASE64(TO_BASE64('Hello')), FROM_BASE64(TO_BASE64('测试'));
+```
+```text
++---------------------------------+----------------------------------+
+| FROM_BASE64(TO_BASE64('Hello')) | FROM_BASE64(TO_BASE64('测试')) |
++---------------------------------+----------------------------------+
+| Hello | 测试 |
++---------------------------------+----------------------------------+
```
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/instr.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/instr.md
index f6899f29641..5a8a5f1a0cb 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/string-functions/instr.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/string-functions/instr.md
@@ -88,4 +88,76 @@ SELECT INSTR('hello', ''), INSTR('', 'world');
+--------------------+---------------------+
| 1 | 0 |
+--------------------+---------------------+
+```
+
+5. Repeated occurrences (returns first match)
+```sql
+SELECT INSTR('abcabc', 'abc'), INSTR('banana', 'a');
+```
+```text
++------------------------+----------------------+
+| INSTR('abcabc', 'abc') | INSTR('banana', 'a') |
++------------------------+----------------------+
+| 1 | 2 |
++------------------------+----------------------+
+```
+
+6. Special characters and symbols
+```sql
+SELECT INSTR('[email protected]', '@'), INSTR('price: $99.99', '$');
+```
+```text
++--------------------------------+-----------------------------+
+| INSTR('[email protected]', '@') | INSTR('price: $99.99', '$') |
++--------------------------------+-----------------------------+
+| 5 | 8 |
++--------------------------------+-----------------------------+
+```
+
+7. UTF-8 multi-byte characters
+```sql
+SELECT INSTR('ṭṛì ḍḍumai hello', 'ḍḍumai'), INSTR('ṭṛì ḍḍumai hello', 'hello');
+```
+```text
++--------------------------------------------------+---------------------------------------------+
+| INSTR('ṭṛì ḍḍumai hello', 'ḍḍumai') | INSTR('ṭṛì ḍḍumai hello',
'hello') |
++--------------------------------------------------+---------------------------------------------+
+| 5 |
12 |
++--------------------------------------------------+---------------------------------------------+
+```
+
+8. Numeric strings
+```sql
+SELECT INSTR('123456789', '456'), INSTR('123-456-789', '-');
+```
+```text
++---------------------------+---------------------------+
+| INSTR('123456789', '456') | INSTR('123-456-789', '-') |
++---------------------------+---------------------------+
+| 4 | 4 |
++---------------------------+---------------------------+
+```
+
+9. Multi-word substring search
+```sql
+SELECT INSTR('The quick brown fox', 'quick'), INSTR('The quick brown fox',
'slow');
+```
+```text
++---------------------------------------+--------------------------------------+
+| INSTR('The quick brown fox', 'quick') | INSTR('The quick brown fox', 'slow')
|
++---------------------------------------+--------------------------------------+
+| 5 | 0
|
++---------------------------------------+--------------------------------------+
+```
+
+10. Path and URL searches
+```sql
+SELECT INSTR('/home/user/file.txt', '/'), INSTR('https://www.example.com',
'://');
+```
+```text
++-----------------------------------+-----------------------------------------+
+| INSTR('/home/user/file.txt', '/') | INSTR('https://www.example.com', '://') |
++-----------------------------------+-----------------------------------------+
+| 1 | 6 |
++-----------------------------------+-----------------------------------------+
```
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/length.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/length.md
index 8a38f996a09..305b97932b7 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/string-functions/length.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/string-functions/length.md
@@ -76,4 +76,76 @@ SELECT LENGTH(NULL);
+--------------+
| NULL |
+--------------+
+```
+
+4. Empty string
+```sql
+SELECT LENGTH('');
+```
+```text
++------------+
+| LENGTH('') |
++------------+
+| 0 |
++------------+
+```
+
+5. Mixed character types
+```sql
+SELECT LENGTH('Hello世界'), CHAR_LENGTH('Hello世界');
+```
+```text
++-----------------------+----------------------------+
+| LENGTH('Hello世界') | CHAR_LENGTH('Hello世界') |
++-----------------------+----------------------------+
+| 11 | 7 |
++-----------------------+----------------------------+
+```
+
+6. Escape characters and ASCII spaces
+```sql
+SELECT LENGTH('\t\n\r'), LENGTH(' ');
+```
+```text
++------------------+--------------+
+| LENGTH('\t\n\r') | LENGTH(' ') |
++------------------+--------------+
+| 3 | 2 |
++------------------+--------------+
+```
+
+7. UTF-8 multi-byte characters versus character count
+```sql
+SELECT LENGTH('ṭṛì'), CHAR_LENGTH('ṭṛì');
+```
+```text
++--------------------+-------------------------+
+| LENGTH('ṭṛì') | CHAR_LENGTH('ṭṛì') |
++--------------------+-------------------------+
+| 8 | 3 |
++--------------------+-------------------------+
+```
+
+8. Emoji (typically 4 bytes per glyph)
+```sql
+SELECT LENGTH('😀😁'), CHAR_LENGTH('😀😁');
+```
+```text
++--------------------+-------------------------+
+| LENGTH('😀😁') | CHAR_LENGTH('😀😁') |
++--------------------+-------------------------+
+| 8 | 2 |
++--------------------+-------------------------+
+```
+
+9. Numeric strings
+```sql
+SELECT LENGTH('12345'), CHAR_LENGTH('12345');
+```
+```text
++-----------------+----------------------+
+| LENGTH('12345') | CHAR_LENGTH('12345') |
++-----------------+----------------------+
+| 5 | 5 |
++-----------------+----------------------+
```
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/locate.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/locate.md
index 64635ccf51f..8ec28e273c9 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/string-functions/locate.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/string-functions/locate.md
@@ -78,4 +78,88 @@ SELECT LOCATE('xyz', 'foobar'), LOCATE('FOO', 'foobar');
+-------------------------+-------------------------+
| 0 | 0 |
+-------------------------+-------------------------+
+```
+
+4. NULL handling
+```sql
+SELECT LOCATE(NULL, 'foobar'), LOCATE('foo', NULL), LOCATE(NULL, NULL);
+```
+```text
++------------------------+---------------------+--------------------+
+| LOCATE(NULL, 'foobar') | LOCATE('foo', NULL) | LOCATE(NULL, NULL) |
++------------------------+---------------------+--------------------+
+| NULL | NULL | NULL |
++------------------------+---------------------+--------------------+
+```
+
+5. Empty-string handling
+```sql
+SELECT LOCATE('', 'foobar'), LOCATE('foo', ''), LOCATE('', '');
+```
+```text
++----------------------+-------------------+----------------+
+| LOCATE('', 'foobar') | LOCATE('foo', '') | LOCATE('', '') |
++----------------------+-------------------+----------------+
+| 1 | 0 | 1 |
++----------------------+-------------------+----------------+
+```
+
+6. Specifying a starting position
+```sql
+SELECT LOCATE('o', 'foobar', 1), LOCATE('o', 'foobar', 2), LOCATE('o',
'foobar', 4);
+```
+```text
++--------------------------+--------------------------+--------------------------+
+| LOCATE('o', 'foobar', 1) | LOCATE('o', 'foobar', 2) | LOCATE('o', 'foobar',
4) |
++--------------------------+--------------------------+--------------------------+
+| 2 | 2 |
0 |
++--------------------------+--------------------------+--------------------------+
+```
+
+7. Boundary values for the position argument
+```sql
+SELECT LOCATE('foo', 'foobar', 0), LOCATE('foo', 'foobar', -1), LOCATE('foo',
'foobar', 10);
+```
+```text
++----------------------------+-----------------------------+-----------------------------+
+| LOCATE('foo', 'foobar', 0) | LOCATE('foo', 'foobar', -1) | LOCATE('foo',
'foobar', 10) |
++----------------------------+-----------------------------+-----------------------------+
+| 0 | 0 |
0 |
++----------------------------+-----------------------------+-----------------------------+
+```
+
+8. UTF-8 substring search
+```sql
+SELECT LOCATE('ṛì', 'ṭṛì ḍḍumai'), LOCATE('ḍḍu', 'ṭṛì ḍḍumai');
+```
+```text
++----------------------------------------+------------------------------------------+
+| LOCATE('ṛì', 'ṭṛì ḍḍumai') | LOCATE('ḍḍu', 'ṭṛì ḍḍumai')
|
++----------------------------------------+------------------------------------------+
+| 2 |
5 |
++----------------------------------------+------------------------------------------+
+```
+
+9. Case sensitivity
+```sql
+SELECT LOCATE('BAR', 'foobar'), LOCATE('Bar', 'foobar'), LOCATE('bar',
'fooBAR');
+```
+```text
++-------------------------+-------------------------+-------------------------+
+| LOCATE('BAR', 'foobar') | LOCATE('Bar', 'foobar') | LOCATE('bar', 'fooBAR') |
++-------------------------+-------------------------+-------------------------+
+| 0 | 0 | 0 |
++-------------------------+-------------------------+-------------------------+
+```
+
+10. Empty substring with a position argument
+```sql
+SELECT LOCATE('', 'foobar', 3), LOCATE('', 'foobar', 7), LOCATE('', '', 1);
+```
+```text
++-------------------------+-------------------------+-------------------+
+| LOCATE('', 'foobar', 3) | LOCATE('', 'foobar', 7) | LOCATE('', '', 1) |
++-------------------------+-------------------------+-------------------+
+| 3 | 0 | 1 |
++-------------------------+-------------------------+-------------------+
```
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/lpad.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/lpad.md
index 62c3050caa8..ccc50323413 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/string-functions/lpad.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/string-functions/lpad.md
@@ -76,4 +76,76 @@ SELECT LPAD(NULL, 5, 'x'), LPAD('hi', NULL, 'x'), LPAD('hi',
5, NULL);
+---------------------+------------------------+----------------------+
| NULL | NULL | NULL |
+---------------------+------------------------+----------------------+
+```
+
+4. Empty string and zero length
+```sql
+SELECT LPAD('', 0, ''), LPAD('hi', 0, 'x'), LPAD('', 5, '*');
+```
+```text
++-----------------+--------------------+------------------+
+| LPAD('', 0, '') | LPAD('hi', 0, 'x') | LPAD('', 5, '*') |
++-----------------+--------------------+------------------+
+| | | ***** |
++-----------------+--------------------+------------------+
+```
+
+5. Empty padding string
+```sql
+SELECT LPAD('hello', 10, ''), LPAD('hi', 2, '');
+```
+```text
++-----------------------+-------------------+
+| LPAD('hello', 10, '') | LPAD('hi', 2, '') |
++-----------------------+-------------------+
+| | hi |
++-----------------------+-------------------+
+```
+
+6. Longer padding string (repeated until len is reached)
+```sql
+SELECT LPAD('123', 10, 'abc'), LPAD('X', 7, 'HELLO');
+```
+```text
++------------------------+-----------------------+
+| LPAD('123', 10, 'abc') | LPAD('X', 7, 'HELLO') |
++------------------------+-----------------------+
+| abcabca123 | HELLOHX |
++------------------------+-----------------------+
+```
+
+7. UTF-8 multi-byte padding
+```sql
+SELECT LPAD('hello', 10, 'ṭṛì'), LPAD('ḍḍumai', 3, 'x');
+```
+```text
++-------------------------------+----------------------------+
+| LPAD('hello', 10, 'ṭṛì') | LPAD('ḍḍumai', 3, 'x') |
++-------------------------------+----------------------------+
+| ṭṛìṭṛhello | ḍḍu |
++-------------------------------+----------------------------+
+```
+
+8. Zero-padding numeric strings
+```sql
+SELECT LPAD('42', 6, '0'), LPAD('1234', 8, '0');
+```
+```text
++--------------------+----------------------+
+| LPAD('42', 6, '0') | LPAD('1234', 8, '0') |
++--------------------+----------------------+
+| 000042 | 00001234 |
++--------------------+----------------------+
+```
+
+9. Negative length
+```sql
+SELECT LPAD('hello', -1, 'x'), LPAD('test', -5, '*');
+```
+```text
++------------------------+-----------------------+
+| LPAD('hello', -1, 'x') | LPAD('test', -5, '*') |
++------------------------+-----------------------+
+| NULL | NULL |
++------------------------+-----------------------+
```
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/rtrim.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/rtrim.md
index b4b12705485..1b9f789fc2e 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/string-functions/rtrim.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/string-functions/rtrim.md
@@ -58,7 +58,19 @@ SELECT rtrim('ababccaab', 'ab') str;
+---------+
```
-3. UTF-8 character support
+3. Default trim only removes ASCII space — `RTRIM` does **not** strip tabs
(`\t`) or newlines (`\n`) without a second argument. Compare `LENGTH` before
and after: only the single trailing ASCII space is stripped; `\t\n` stay.
+```sql
+SELECT LENGTH('hello world \t\n '), LENGTH(RTRIM('hello world \t\n '));
+```
+```text
++------------------------------+-------------------------------------+
+| LENGTH('hello world \t\n ') | LENGTH(RTRIM('hello world \t\n ')) |
++------------------------------+-------------------------------------+
+| 16 | 15 |
++------------------------------+-------------------------------------+
+```
+
+4. UTF-8 character support
```sql
SELECT rtrim('ṭṛì ḍḍumai ');
```
@@ -70,7 +82,7 @@ SELECT rtrim('ṭṛì ḍḍumai ');
+---------------------------+
```
-4. No matching suffix, return original string
+5. No matching suffix, return original string
```sql
SELECT rtrim('Hello World', 'xyz');
```
@@ -82,7 +94,7 @@ SELECT rtrim('Hello World', 'xyz');
+---------------------------------+
```
-5. NULL value handling
+6. NULL value handling
```sql
SELECT rtrim(NULL), rtrim('Hello', NULL);
```
@@ -94,7 +106,7 @@ SELECT rtrim(NULL), rtrim('Hello', NULL);
+-------------+------------------------+
```
-6. Empty string handling
+7. Empty string handling
```sql
SELECT rtrim(''), rtrim('abc', '');
```
@@ -106,7 +118,7 @@ SELECT rtrim(''), rtrim('abc', '');
+-----------+-------------------+
```
-7. Repeated trailing pattern removal
+8. Repeated trailing pattern removal
```sql
SELECT rtrim('abcabcabc', 'abc');
```
@@ -118,7 +130,7 @@ SELECT rtrim('abcabcabc', 'abc');
+-------------------------------+
```
-8. Multiple occurrences, remove only trailing match
+9. Multiple occurrences, remove only trailing match
```sql
SELECT rtrim('HelloHelloWorld', 'Hello');
```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
index 4724e495ac9..533e5d046b8 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
@@ -164,6 +164,30 @@ SELECT SUBSTRING('ṭṛì ḍḍumai hello', 5, 6);
+--------------------------------------+
```
+11. Empty source string
+```sql
+SELECT substring('', 1, 3);
+```
+```text
++---------------------+
+| substring('', 1, 3) |
++---------------------+
+| |
++---------------------+
+```
+
+12. NULL passed directly to `substring` (the `MID` alias case is in example 8)
+```sql
+SELECT substring(NULL, 1, 3);
+```
+```text
++-----------------------+
+| substring(NULL, 1, 3) |
++-----------------------+
+| NULL |
++-----------------------+
+```
+
### Keywords
SUBSTRING, SUBSTR, MID
\ No newline at end of file
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
index 04ae68fee9d..cb93c8ca5e6 100644
--- a/docs/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
+++ b/docs/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
@@ -46,16 +46,16 @@ SELECT trim(' ab d ') str;
+------+
```
-2. Remove specified strings from both ends
+2. Remove specified strings from both ends — `trim(str, rhs)` repeatedly
strips `<rhs>` from both the leading and trailing ends of `<str>` until neither
end starts/ends with `<rhs>`.
```sql
SELECT trim('ababccaab', 'ab') str;
```
```text
-+---------+
-| str |
-+---------+
-| ababcca |
-+---------+
++------+
+| str |
++------+
+| cca |
++------+
```
3. UTF-8 character support
@@ -130,6 +130,18 @@ SELECT trim('abcHelloabc', 'abc');
+--------------------------------+
```
+9. UTF-8 string with a UTF-8 trim pattern — only the leading `ṭṛì` is stripped
because the trailing end does not match the pattern (`+++`), so trim stops
there.
+```sql
+SELECT trim('ṭṛì ḍḍumai+++', 'ṭṛì');
+```
+```text
++--------------------------------------------+
+| trim('ṭṛì ḍḍumai+++', 'ṭṛì') |
++--------------------------------------------+
+| ḍḍumai+++ |
++--------------------------------------------+
+```
+
### Keywords
TRIM
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/other-functions/field.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/other-functions/field.md
index 21bdc6685cc..15afd09f60f 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/other-functions/field.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/other-functions/field.md
@@ -29,6 +29,20 @@ FIELD(<expr>, <param> [, ...])
## 举例
+直接使用 `FIELD` 查找位置(基于 1 的索引):
+
+```sql
+SELECT FIELD(2, 3, 1, 2, 5);
+```
+
+```text
++----------------------+
+| FIELD(2, 3, 1, 2, 5) |
++----------------------+
+| 3 |
++----------------------+
+```
+
```sql
SELECT k1, k7 FROM baseall WHERE k1 IN (1,2,3) ORDER BY FIELD(k1,2,1,3);
```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/ltrim.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/ltrim.md
index 27387e43557..61910ae87a7 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/ltrim.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/ltrim.md
@@ -65,16 +65,16 @@ SELECT LTRIM('ababccaab', 'ab');
+----------------------------+
```
-3. 多种空白字符处理
+3. 默认只剥除 ASCII 空格 —— `LTRIM` 不带第二个参数时只剥除前导 ASCII 空格,**不**剥除制表符 (`\t`) 或换行符
(`\n`)。通过比较原串与 LTRIM 后字符串的长度可以验证:只有开头的两个 ASCII 空格被剥掉,`\t\n` 保留在结果中。
```sql
-SELECT LTRIM(' \t\n hello world');
+SELECT LENGTH(' \t\n hello world'), LENGTH(LTRIM(' \t\n hello world'));
```
```text
-+--------------------------------+
-| LTRIM(' \t\n hello world') |
-+--------------------------------+
-| hello world |
-+--------------------------------+
++-------------------------------+--------------------------------------+
+| LENGTH(' \t\n hello world') | LENGTH(LTRIM(' \t\n hello world')) |
++-------------------------------+--------------------------------------+
+| 17 | 15 |
++-------------------------------+--------------------------------------+
```
4. NULL 值处理
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
index 7e7609a71d0..ca4cbf1318d 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
@@ -175,3 +175,15 @@ SELECT MID(NULL, 2);
| NULL |
+--------------+
```
+
+12. 使用别名 SUBSTR
+```sql
+SELECT SUBSTR('Hello World', 7, 5);
+```
+```text
++-----------------------------+
+| SUBSTR('Hello World', 7, 5) |
++-----------------------------+
+| World |
++-----------------------------+
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
index f2bc6947e78..e3074307711 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
@@ -109,7 +109,7 @@ SELECT trim(NULL);
7. 空字符
```sql
-SELECT trim('xxxhelloxxx', ''),trim('', 'x');;
+SELECT trim('xxxhelloxxx', ''), trim('', 'x');
```
```text
+-------------------------+---------------+
@@ -119,6 +119,42 @@ SELECT trim('xxxhelloxxx', ''),trim('', 'x');;
+-------------------------+---------------+
```
+8. 前后缀不匹配,原样返回
+```sql
+SELECT trim('Hello World', 'xyz');
+```
+```text
++----------------------------+
+| trim('Hello World', 'xyz') |
++----------------------------+
+| Hello World |
++----------------------------+
+```
+
+9. 重复模式:从两端反复剥除,直到两端都不再以 `<rhs>` 起止
+```sql
+SELECT trim('abcabcabc', 'abc');
+```
+```text
++--------------------------+
+| trim('abcabcabc', 'abc') |
++--------------------------+
+| |
++--------------------------+
+```
+
+10. 两端对称剥除:当 `<rhs>` 同时出现在两端时一次性都去掉,中间保留
+```sql
+SELECT trim('abcHelloabc', 'abc');
+```
+```text
++----------------------------+
+| trim('abcHelloabc', 'abc') |
++----------------------------+
+| Hello |
++----------------------------+
+```
+
### Keywords
TRIM
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]