mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Update tests and docs related to splitByString
This commit is contained in:
parent
3c5670c0e2
commit
ae2c60d224
@ -5,3 +5,5 @@
|
|||||||
['a','b','c','d','e']
|
['a','b','c','d','e']
|
||||||
['hello','world']
|
['hello','world']
|
||||||
['gbye','bug']
|
['gbye','bug']
|
||||||
|
['']
|
||||||
|
[]
|
||||||
|
@ -4,3 +4,5 @@ select splitByString('ab', 'ababab');
|
|||||||
select splitByString('ababab', 'ababab');
|
select splitByString('ababab', 'ababab');
|
||||||
select splitByString('', 'abcde');
|
select splitByString('', 'abcde');
|
||||||
select splitByString(', ', x) from (select arrayJoin(['hello, world', 'gbye, bug']) x);
|
select splitByString(', ', x) from (select arrayJoin(['hello, world', 'gbye, bug']) x);
|
||||||
|
select splitByString('ab', '');
|
||||||
|
select splitByString('', '');
|
||||||
|
@ -1,11 +1,31 @@
|
|||||||
# Functions for splitting and merging strings and arrays
|
# Functions for splitting and merging strings and arrays
|
||||||
|
|
||||||
## splitByChar(separator, s)
|
## splitByChar
|
||||||
|
|
||||||
Splits a string into substrings separated by 'separator'.'separator' must be a string constant consisting of exactly one character.
|
Splits a string into substrings separated by a specified character. It uses a constant string `separator` which consisting of exactly one character.
|
||||||
Returns an array of selected substrings. Empty substrings may be selected if the separator occurs at the beginning or end of the string, or if there are multiple consecutive separators.
|
|
||||||
|
|
||||||
**Example:**
|
**Syntax**
|
||||||
|
|
||||||
|
```sql
|
||||||
|
splitByChar(<separator>, <s>)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `separator` — The separator which should contain exactly one character. [String](../../data_types/string.md).
|
||||||
|
- `s` — The string to split. [String](../../data_types/string.md).
|
||||||
|
|
||||||
|
**Returned value(s)**
|
||||||
|
|
||||||
|
Returns an array of selected substrings. Empty substrings may be selected when:
|
||||||
|
|
||||||
|
* A separator occurs at the beginning or end of the string;
|
||||||
|
* There are multiple consecutive separators;
|
||||||
|
* The original string `s` is empty.
|
||||||
|
|
||||||
|
Type: [Array](../../data_types/array.md) of [String](../../data_types/string.md).
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT splitByChar(',', '1,2,3,abcde')
|
SELECT splitByChar(',', '1,2,3,abcde')
|
||||||
@ -16,11 +36,32 @@ SELECT splitByChar(',', '1,2,3,abcde')
|
|||||||
└─────────────────────────────────┘
|
└─────────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
## splitByString(separator, s)
|
## splitByString
|
||||||
|
|
||||||
The same as above, but it uses a string of multiple characters as the separator. If the string is empty, it will split the string into an array of single characters.
|
Splits a string into substrings separated by a string. It uses a constant string `separator` of multiple characters as the separator. If the string `separator` is empty, it will split the string `s` into an array of single characters.
|
||||||
|
|
||||||
**Example:**
|
**Syntax**
|
||||||
|
|
||||||
|
```sql
|
||||||
|
splitByString(<separator>, <s>)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `separator` — The separator. [String](../../data_types/string.md).
|
||||||
|
- `s` — The string to split. [String](../../data_types/string.md).
|
||||||
|
|
||||||
|
**Returned value(s)**
|
||||||
|
|
||||||
|
Returns an array of selected substrings. Empty substrings may be selected when:
|
||||||
|
|
||||||
|
* A non-empty separator occurs at the beginning or end of the string;
|
||||||
|
* There are multiple consecutive non-empty separators;
|
||||||
|
* The original string `s` is empty while the separator is not empty.
|
||||||
|
|
||||||
|
Type: [Array](../../data_types/array.md) of [String](../../data_types/string.md).
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT splitByString(', ', '1, 2 3, 4,5, abcde')
|
SELECT splitByString(', ', '1, 2 3, 4,5, abcde')
|
||||||
@ -49,7 +90,7 @@ Returns the string.
|
|||||||
|
|
||||||
Selects substrings of consecutive bytes from the ranges a-z and A-Z.Returns an array of substrings.
|
Selects substrings of consecutive bytes from the ranges a-z and A-Z.Returns an array of substrings.
|
||||||
|
|
||||||
**Example:**
|
**Example**
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT alphaTokens('abca1abc')
|
SELECT alphaTokens('abca1abc')
|
||||||
|
Loading…
Reference in New Issue
Block a user