SPLIT_PART

All functions > STRING > SPLIT_PART

Returns a specific part of a string after splitting by a delimiter.

Signatures

Returns: The specified part after splitting, or empty string if index out of range

SPLIT_PART(string: VARCHAR, delimiter: VARCHAR, index: BIGINT) → VARCHAR
sql
ParameterTypeRequiredDescription
stringVARCHARYesString to split
delimiterVARCHARYesDelimiter to split on
indexBIGINTYes1-indexed position of the part to return

Notes

  • Index is 1-based (first part is 1, not 0)
  • Returns empty string if index is out of bounds
  • More efficient than SPLIT when only one part is needed

Examples

FeatureQL
SELECT
    f1 := SPLIT_PART('2024-01-15', '-', 1),  -- Get year from date
    f2 := SPLIT_PART('2024-01-15', '-', 2),  -- Get month from date
    f3 := SPLIT_PART('2024-01-15', '-', 3),  -- Get day from date
    f4 := SPLIT_PART('apple-banana-cherry', '-', 2),  -- Get middle element
    f5 := SPLIT_PART('single', '-', 1)  -- No delimiter found
;
Result
f1 VARCHARf2 VARCHARf3 VARCHARf4 VARCHARf5 VARCHAR
20240115bananasingle

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19