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
ParameterTypeRequiredDescription
stringVARCHARYesString to split
delimiterVARCHARYesDelimiter to split on
limitBIGINTNoMaximum size of the result array (optional); the last element holds the remainder

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 yields ARRAY['']
  • An empty delimiter is invalid and fails when the query runs
  • If either argument is NULL the result is NULL (use NULL(VARCHAR); bare NULL fails inference)
  • Optional limit caps the result array size (last element keeps the unsplit remainder); same semantics on every SQL backend

Examples

FeatureQL
SELECT
    -- Basic split
    f1 := SPLIT('apple,banana,cherry', ','),
    -- Dash delimiter
    f2 := SPLIT('one-two-three', '-'),
    -- Space delimiter
    f3 := SPLIT('hello world', ' '),
    -- No delimiter found
    f4 := SPLIT('no delimiter', ','),
    -- Empty input string
    f5 := SPLIT('', ','),
    -- NULL yields NULL
    f6 := SPLIT(NULL(VARCHAR), ','),
    -- With limit (max array size)
    f7 := SPLIT('a-b-c-d', '-', 3)
;
Result
f1 ARRAYf2 ARRAYf3 ARRAYf4 ARRAYf5 ARRAYf6 ARRAYf7 ARRAY
[apple, banana, cherry][one, two, three][hello, world][no delimiter][(empty)]NULL[a, b, c-d]