Docs: Follow-up to #71441

This commit is contained in:
Robert Schulze 2024-12-06 13:19:55 +00:00
parent aa2a74a565
commit 52fc14eb02
No known key found for this signature in database
GPG Key ID: 26703B55FB13728A

View File

@ -253,7 +253,11 @@ SELECT format('{} {}', 'Hello', 'World')
## translate
Replaces characters in the string `s` using a one-to-one character mapping defined by `from` and `to` strings. `from` and `to` must be constant ASCII strings. Non-ASCII characters in the original string are not modified. If the number of characters in `from` list is larger than the `to` list, non overlapping characters will be deleted from the input string.
Replaces characters in the string `s` using a one-to-one character mapping defined by `from` and `to` strings.
`from` and `to` must be constant ASCII strings.
If `from` and `to` have equal sizes, each occurrence of the 1st character of `first` in `s` is replaced by the 1st character of `to`, the 2nd character of `first` in `s` is replaced by the 2nd character of `to`, etc.
If `from` contains more characters than `to`, all occurrences of the characters at the end of `from` that have no corresponding character in `to` are deleted from `s`.
Non-ASCII characters in `s` are not modified by the function.
**Syntax**
@ -275,6 +279,20 @@ Result:
└───────────────┘
```
`from` and `to` arguments have different lengths:
``` sql
SELECT translate('clickhouse', 'clickhouse', 'CLICK') AS res
```
Result:
``` text
┌─res───┐
│ CLICK │
└───────┘
```
## translateUTF8
Like [translate](#translate) but assumes `s`, `from` and `to` are UTF-8 encoded strings.