mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #62589 from Blargian/document_left_right_XYZ
[Docs] add missing `left`, `right` functions and their variants.
This commit is contained in:
commit
542364e2b2
@ -102,6 +102,100 @@ Alias:
|
||||
- `CHAR_LENGTH`
|
||||
- `CHARACTER_LENGTH`
|
||||
|
||||
## left
|
||||
|
||||
Returns a substring of string `s` with a specified `offset` starting from the left.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
left(s, offset)
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `s`: The string to calculate a substring from. [String](../../sql-reference/data-types/string.md) or [FixedString](../../sql-reference/data-types/fixedstring.md).
|
||||
- `offset`: The number of bytes of the offset. [UInt*](../data-types/int-uint).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- For positive `offset`: A substring of `s` with `offset` many bytes, starting from the left of the string.
|
||||
- For negative `offset`: A substring of `s` with `length(s) - |offset|` bytes, starting from the left of the string.
|
||||
- An empty string if `length` is 0.
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT left('Hello', 3);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
Hel
|
||||
```
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT left('Hello', -3);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
He
|
||||
```
|
||||
|
||||
## leftUTF8
|
||||
|
||||
Returns a substring of a UTF-8 encoded string `s` with a specified `offset` starting from the left.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
leftUTF8(s, offset)
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `s`: The UTF-8 encoded string to calculate a substring from. [String](../../sql-reference/data-types/string.md) or [FixedString](../../sql-reference/data-types/fixedstring.md).
|
||||
- `offset`: The number of bytes of the offset. [UInt*](../data-types/int-uint).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- For positive `offset`: A substring of `s` with `offset` many bytes, starting from the left of the string.
|
||||
- For negative `offset`: A substring of `s` with `length(s) - |offset|` bytes, starting from the left of the string.
|
||||
- An empty string if `length` is 0.
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT leftUTF8('Привет', 4);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
Прив
|
||||
```
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT leftUTF8('Привет', -4);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
Пр
|
||||
```
|
||||
|
||||
## leftPad
|
||||
|
||||
Pads a string from the left with spaces or with a specified string (multiple times, if needed) until the resulting string reaches the specified `length`.
|
||||
@ -176,6 +270,100 @@ Result:
|
||||
└─────────────────────────────┴────────────────────────┘
|
||||
```
|
||||
|
||||
## right
|
||||
|
||||
Returns a substring of string `s` with a specified `offset` starting from the right.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
right(s, offset)
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `s`: The string to calculate a substring from. [String](../../sql-reference/data-types/string.md) or [FixedString](../../sql-reference/data-types/fixedstring.md).
|
||||
- `offset`: The number of bytes of the offset. [UInt*](../data-types/int-uint).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- For positive `offset`: A substring of `s` with `offset` many bytes, starting from the right of the string.
|
||||
- For negative `offset`: A substring of `s` with `length(s) - |offset|` bytes, starting from the right of the string.
|
||||
- An empty string if `length` is 0.
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT right('Hello', 3);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
llo
|
||||
```
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT right('Hello', -3);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
lo
|
||||
```
|
||||
|
||||
## rightUTF8
|
||||
|
||||
Returns a substring of UTF-8 encoded string `s` with a specified `offset` starting from the right.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
rightUTF8(s, offset)
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
- `s`: The UTF-8 encoded string to calculate a substring from. [String](../../sql-reference/data-types/string.md) or [FixedString](../../sql-reference/data-types/fixedstring.md).
|
||||
- `offset`: The number of bytes of the offset. [UInt*](../data-types/int-uint).
|
||||
|
||||
**Returned value**
|
||||
|
||||
- For positive `offset`: A substring of `s` with `offset` many bytes, starting from the right of the string.
|
||||
- For negative `offset`: A substring of `s` with `length(s) - |offset|` bytes, starting from the right of the string.
|
||||
- An empty string if `length` is 0.
|
||||
|
||||
**Example**
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT rightUTF8('Привет', 4);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
ивет
|
||||
```
|
||||
|
||||
Query:
|
||||
|
||||
```sql
|
||||
SELECT rightUTF8('Привет', -4);
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```response
|
||||
ет
|
||||
```
|
||||
|
||||
## rightPad
|
||||
|
||||
Pads a string from the right with spaces or with a specified string (multiple times, if needed) until the resulting string reaches the specified `length`.
|
||||
|
@ -1844,6 +1844,7 @@ laravel
|
||||
largestTriangleThreeBuckets
|
||||
latencies
|
||||
ldap
|
||||
leftUTF
|
||||
leftPad
|
||||
leftPadUTF
|
||||
lemmatization
|
||||
@ -2317,6 +2318,7 @@ retriable
|
||||
reverseUTF
|
||||
rightPad
|
||||
rightPadUTF
|
||||
rightUTF
|
||||
risc
|
||||
riscv
|
||||
ro
|
||||
|
Loading…
Reference in New Issue
Block a user