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 7f3b1a7fc17 [fix](doc) trim/field/substring: bidirectional en/zh sync
(#3839)
7f3b1a7fc17 is described below
commit 7f3b1a7fc173de8f5529c08c16c319434fa3a478
Author: boluor <[email protected]>
AuthorDate: Fri May 29 19:59:15 2026 -0700
[fix](doc) trim/field/substring: bidirectional en/zh sync (#3839)
## Summary
Careful bidirectional sync for three pages where EN and ZH had each
grown distinct non-redundant examples. Each addition was verified
end-to-end against Doris 4.1.1; expected outputs are pasted from the
cluster, not transcribed.
### `trim.md`
- **EN ← ZH**: add example 9 — UTF-8 string with a UTF-8 trim pattern.
Demonstrates that `trim('ṭṛì ḍḍumai+++', 'ṭṛì')` strips only the leading
`ṭṛì` (trailing `+++` doesn't match the pattern so trim stops there). EN
previously had only a default-space UTF-8 example.
- **ZH ← EN**: add examples 8/9/10 — no-match returns original,
repeated-pattern strips until exhausted, and asymmetric removal
(multi-char pattern from both ends). EN had these corner cases as 4/7/8;
ZH didn't.
- **ZH fix**: trailing `;;` (double semicolon) on example 7 → single
`;`.
### `field.md`
- **EN ← ZH**: extend the `class_test` setup with a `NULL` row, then add
two examples that exercise NULL handling under FIELD-based custom
ordering — DESC variant (NULL ends up last because FIELD = 0) and NULLS
FIRST (NULL placement independent of sort direction). Updated the
existing ASC example's expected output to include the NULL row that the
new setup row produces.
- **ZH ← EN**: add the simple `SELECT FIELD(2, 3, 1, 2, 5)` example that
introduces the 1-based position semantics before the ORDER BY use case.
### `substring.md`
- **EN ← ZH**: add example 12 — `substring(NULL, 1, 3)` (NULL passed to
the function directly; the `MID` alias variant was already example 8).
- **ZH ← EN**: add example 12 — `SUBSTR('Hello World', 7, 5)` showing
the SUBSTR alias.
## Scope note
Two other P1-both-extra pages remain intentionally not in this PR:
- `strright.md` — EN and ZH are already at parity; the only diff is a
cosmetic "syntax block lists the RIGHT alias twice" formatting
difference. Not worth a doc change.
- `array-count.md` — EN and ZH each have substantially different example
sets covering the same teaching points with different idioms (e.g. EN
uses `size(array_filter(...)) > 0` to show the "wrap inner higher-order
in a scalar" pattern; ZH uses recursive `array_count(...
array_count(...) ...)`). Both are valid; mechanically merging them risks
a confusing doc.
🤖 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 | 14 +++++++
.../scalar-functions/string-functions/substring.md | 12 ++++++
.../scalar-functions/string-functions/trim.md | 38 +++++++++++++++++-
.../scalar-functions/other-functions/field.md | 46 +++++++++++++++++++++-
.../scalar-functions/string-functions/substring.md | 12 ++++++
.../scalar-functions/string-functions/trim.md | 12 ++++++
6 files changed, 132 insertions(+), 2 deletions(-)
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/other-functions/field.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/other-functions/field.md
index 4bc68c80986..e2316990cdd 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/other-functions/field.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/other-functions/field.md
@@ -51,6 +51,20 @@ INSERT INTO class_test VALUES
(NULL);
```
+直接使用 `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/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
index 7e7609a71d0..ca4cbf1318d 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/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/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
index f2bc6947e78..e3074307711 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/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
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/other-functions/field.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/other-functions/field.md
index ee4c1bd4cd3..2dd9ebe5985 100644
---
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/other-functions/field.md
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/other-functions/field.md
@@ -50,7 +50,8 @@ PROPERTIES ("replication_num" = "1");
INSERT INTO class_test VALUES
('Suzi'), ('Suzi'),
('Ben'), ('Ben'),
- ('Henry'), ('Henry');
+ ('Henry'), ('Henry'),
+ (NULL);
```
```sql
@@ -79,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');
```
@@ -87,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/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
index 1585baa071b..533e5d046b8 100644
---
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/substring.md
@@ -176,6 +176,18 @@ SELECT 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/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
index 3201e5aed70..cb93c8ca5e6 100644
---
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/trim.md
@@ -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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]