ARRAY_JOIN
All functions > ARRAY > ARRAY_JOIN
Joins the elements of an array into a single string using a specified delimiter.
Signatures
Returns: A single string with array elements joined by the delimiter
ARRAY_JOIN(array: ARRAY<T>, delimiter: VARCHAR, [null_replacement: VARCHAR]) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
array | ARRAY<T> | Yes | Array of strings to join together |
delimiter | VARCHAR | Yes | String to insert between array elements |
null_replacement | VARCHAR | No | Optional replacement string for NULL values |
Notes
- Joins array elements into a single string using the specified delimiter
- NULL values are omitted unless a replacement string is provided
- Empty arrays return an empty string
- Single element arrays return just that element (no delimiter)
- Useful for creating CSV-like output or human-readable lists
Examples
FeatureQL
SELECT
f1 := ARRAY_JOIN(ARRAY['A', 'B', 'C'], ', '), -- Join with comma and space
f2 := ARRAY_JOIN(ARRAY['apple', 'banana', 'cherry'], '|'), -- Join with pipe delimiter
f3 := ARRAY_JOIN(ARRAY['hello', 'world'], ''), -- Join with no delimiter
f4 := ARRAY_JOIN(ARRAY['one'], ','), -- Single element array
f5 := ARRAY_JOIN(ARRAY[]::VARCHAR[], ','), -- Empty array returns empty string
f6 := ARRAY_JOIN(ARRAY['A', NULL::VARCHAR, 'C'], ','), -- NULL becomes empty string
f7 := ARRAY_JOIN(ARRAY['A', NULL::VARCHAR, 'C'], ',', 'empty') -- NULL replacement
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR | f5 VARCHAR | f6 VARCHAR | f7 VARCHAR |
|---|---|---|---|---|---|---|
| A, B, C | apple|banana|cherry | helloworld | one | (empty) | A,C | A,empty,C |
On this page