Skip to main content

SPLIT_BY_STRING

Description​

Split the input string into a string array according to the specified string.

Syntax​

SPLIT_BY_STRING ( <str>, <separator> )

Parameters​

ParameterDescription
<str>The string to be split.
<separator>The string used for splitting.

Return Value​

Returns a string array split according to the specified string. Special cases:

  • If any of the parameters is NULL, NULL is returned.
  • When <separator> is an empty string, <str> will be split to byte sequence.

Examples​

SELECT split_by_string('hello','l');
+-------------------------------+
| split_by_string('hello', 'l') |
+-------------------------------+
| ["he", "", "o"] |
+-------------------------------+
SELECT split_by_string('hello','');
+------------------------------+
| split_by_string('hello', '') |
+------------------------------+
| ["h", "e", "l", "l", "o"] |
+------------------------------+