SPLIT()
All functions > STRING > SPLIT()
Returns an array of substrings from a string split by a delimiter.
Signatures
Returns: Array of substrings
SPLIT(string: VARCHAR, delimiter: VARCHAR, [limit: BIGINT]) → ARRAYVARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String to split |
delimiter | VARCHAR | Yes | Delimiter to split on |
limit | BIGINT | No | Maximum number of splits (optional) |
Notes
- If the delimiter does not appear, the result is a one-element array containing the original string
- Empty segments between delimiters appear as empty strings in the result
- Splitting
''with a non-empty delimiter yieldsARRAY[''] - An empty delimiter is invalid and fails when the query runs
- If either argument is NULL the result is NULL (use
NULL(VARCHAR); bareNULLfails inference) - A maximum split count (third argument) is only accepted when supported; otherwise omit it (or use
SPLIT_PARTfor one segment)
Examples
FeatureQL
SELECT
f1 := SPLIT('apple,banana,cherry', ','), -- Basic split
f2 := SPLIT('one-two-three', '-'), -- Dash delimiter
f3 := SPLIT('hello world', ' '), -- Space delimiter
f4 := SPLIT('no delimiter', ','), -- No delimiter found
f5 := SPLIT('', ','), -- Empty input string
f6 := SPLIT(NULL(VARCHAR), ',') -- NULL yields NULL
;Result
| f1 ARRAY | f2 ARRAY | f3 ARRAY | f4 ARRAY | f5 ARRAY | f6 ARRAY |
|---|---|---|---|---|---|
| [apple, banana, cherry] | [one, two, three] | [hello, world] | [no delimiter] | [(empty)] | NULL |
On this page