-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into recluster_dis
- Loading branch information
Showing
104 changed files
with
1,515 additions
and
627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: SPLIT | ||
--- | ||
import FunctionDescription from '@site/src/components/FunctionDescription'; | ||
|
||
<FunctionDescription description="Introduced or updated: v1.2.164"/> | ||
|
||
Splits a string using a specified delimiter and returns the resulting parts as an array. | ||
|
||
See also: [SPLIT_PART](split_part.md) | ||
|
||
## Syntax | ||
|
||
```sql | ||
SPLIT('<input_string>', '<delimiter>') | ||
``` | ||
|
||
## Return Type | ||
|
||
Array of strings. SPLIT returns NULL when either the input string or the delimiter is NULL. | ||
|
||
## Examples | ||
|
||
```sql | ||
-- Use a space as the delimiter | ||
-- SPLIT returns an array with two parts. | ||
SELECT SPLIT('Databend Cloud', ' '); | ||
|
||
split('databend cloud', ' ')| | ||
----------------------------+ | ||
['Databend','Cloud'] | | ||
|
||
-- Use an empty string as the delimiter or a delimiter that does not exist in the input string | ||
-- SPLIT returns an array containing the entire input string as a single part. | ||
SELECT SPLIT('Databend Cloud', ''); | ||
|
||
split('databend cloud', '')| | ||
---------------------------+ | ||
['Databend Cloud'] | | ||
|
||
SELECT SPLIT('Databend Cloud', ','); | ||
|
||
split('databend cloud', ',')| | ||
----------------------------+ | ||
['Databend Cloud'] | | ||
|
||
-- Use ' ' (tab) as the delimiter | ||
-- SPLIT returns an array with timestamp, log level, and message. | ||
|
||
SELECT SPLIT('2023-10-19 15:30:45 INFO Log message goes here', ' '); | ||
|
||
split('2023-10-19 15:30:45\tinfo\tlog message goes here', '\t')| | ||
---------------------------------------------------------------+ | ||
['2023-10-19 15:30:45','INFO','Log message goes here'] | | ||
``` |
67 changes: 67 additions & 0 deletions
67
docs/doc/15-sql-functions/40-string-functions/split_part.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
title: SPLIT_PART | ||
--- | ||
import FunctionDescription from '@site/src/components/FunctionDescription'; | ||
|
||
<FunctionDescription description="Introduced or updated: v1.2.164"/> | ||
|
||
Splits a string using a specified delimiter and returns the specified part. | ||
|
||
See also: [SPLIT](split.md) | ||
|
||
## Syntax | ||
|
||
```sql | ||
SPLIT_PART('<input_string>', '<delimiter>', '<position>') | ||
``` | ||
|
||
The *position* argument specifies which part to return. It uses a 1-based index but can also accept positive, negative, or zero values: | ||
|
||
- If *position* is a positive number, it returns the part at the position from the left to the right, or NULL if it doesn't exist. | ||
- If *position* is a negative number, it returns the part at the position from the right to the left, or NULL if it doesn't exist. | ||
- If *position* is 0, it is treated as 1, effectively returning the first part of the string. | ||
|
||
## Return Type | ||
|
||
String. SPLIT_PART returns NULL when either the input string, the delimiter, or the position is NULL. | ||
|
||
## Examples | ||
|
||
```sql | ||
-- Use a space as the delimiter | ||
-- SPLIT_PART returns a specific part. | ||
SELECT SPLIT_PART('Databend Cloud', ' ', 1); | ||
|
||
split_part('databend cloud', ' ', 1)| | ||
------------------------------------+ | ||
Databend | | ||
|
||
-- Use an empty string as the delimiter or a delimiter that does not exist in the input string | ||
-- SPLIT_PART returns the entire input string. | ||
SELECT SPLIT_PART('Databend Cloud', '', 1); | ||
|
||
split_part('databend cloud', '', 1)| | ||
-----------------------------------+ | ||
Databend Cloud | | ||
|
||
SELECT SPLIT_PART('Databend Cloud', ',', 1); | ||
|
||
split_part('databend cloud', ',', 1)| | ||
------------------------------------+ | ||
Databend Cloud | | ||
|
||
-- Use ' ' (tab) as the delimiter | ||
-- SPLIT_PART returns individual fields. | ||
SELECT SPLIT_PART('2023-10-19 15:30:45 INFO Log message goes here', ' ', 3); | ||
|
||
split_part('2023-10-19 15:30:45 info log message goes here', ' ', 3)| | ||
--------------------------------------------------------------------------+ | ||
Log message goes here | | ||
|
||
-- SPLIT_PART returns an empty string as the specified part does not exist at all. | ||
SELECT SPLIT_PART('2023-10-19 15:30:45 INFO Log message goes here', ' ', 4); | ||
|
||
split_part('2023-10-19 15:30:45 info log message goes here', ' ', 4)| | ||
--------------------------------------------------------------------------+ | ||
| | ||
``` |
Oops, something went wrong.