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
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String to split |
delimiter | VARCHAR | Yes | Delimiter to split on |
index | BIGINT | Yes | 1-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 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR | f5 VARCHAR |
|---|---|---|---|---|
| 2024 | 01 | 15 | banana | single |
On this page