mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Update tests and docs for string splitting functions
This commit is contained in:
parent
08f9413e64
commit
c115757e79
@ -0,0 +1,7 @@
|
||||
['cde','cde']
|
||||
['','cde','cde','']
|
||||
['','','','']
|
||||
['','']
|
||||
['a','b','c','d','e']
|
||||
['hello','world']
|
||||
['gbye','bug']
|
6
dbms/tests/queries/0_stateless/01100_split_by_string.sql
Normal file
6
dbms/tests/queries/0_stateless/01100_split_by_string.sql
Normal file
@ -0,0 +1,6 @@
|
||||
select splitByString('ab', 'cdeabcde');
|
||||
select splitByString('ab', 'abcdeabcdeab');
|
||||
select splitByString('ab', 'ababab');
|
||||
select splitByString('ababab', 'ababab');
|
||||
select splitByString('', 'abcde');
|
||||
select splitByString(', ', x) from (select arrayJoin(['hello, world', 'gbye, bug']) x);
|
@ -5,9 +5,40 @@
|
||||
Splits a string into substrings separated by 'separator'.'separator' must be a string constant 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:**
|
||||
|
||||
```sql
|
||||
SELECT splitByChar(',', '1,2,3,abcde')
|
||||
```
|
||||
```text
|
||||
┌─splitByChar(',', '1,2,3,abcde')─┐
|
||||
│ ['1','2','3','abcde'] │
|
||||
└─────────────────────────────────┘
|
||||
```
|
||||
|
||||
## splitByString(separator, s)
|
||||
|
||||
The same as above, but it uses a string of multiple characters as the separator. The string must be non-empty.
|
||||
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.
|
||||
|
||||
**Example:**
|
||||
|
||||
```sql
|
||||
SELECT splitByString(', ', '1, 2 3, 4,5, abcde')
|
||||
```
|
||||
```text
|
||||
┌─splitByString(', ', '1, 2 3, 4,5, abcde')─┐
|
||||
│ ['1','2 3','4,5','abcde'] │
|
||||
└───────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
```sql
|
||||
SELECT splitByString('', 'abcde')
|
||||
```
|
||||
```text
|
||||
┌─splitByString('', 'abcde')─┐
|
||||
│ ['a','b','c','d','e'] │
|
||||
└────────────────────────────┘
|
||||
```
|
||||
|
||||
## arrayStringConcat(arr\[, separator\])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user