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
- An empty array, or one of NULL elements only, returns NULL (as STRING_AGG over an empty set); write COALESCE(ARRAY_JOIN(a, s), '') for ''
- Single element arrays return just that element (no delimiter)
- Useful for creating CSV-like output or human-readable lists
Availability
| Status | Backends |
|---|---|
| Not available | mysql |
Aliases
JOINARRAY_TO_STRING
See also
Examples
FeatureQL
-- Delimiter read from a column
RETURN
-- Join with comma and space
f1 := ARRAY_JOIN(ARRAY('A', 'B', 'C'), ', '),
-- Join with pipe delimiter
f2 := ARRAY_JOIN(ARRAY('apple', 'banana', 'cherry'), '|'),
-- Join with no delimiter
f3 := ARRAY_JOIN(ARRAY('hello', 'world'), ''),
-- Single element array
f4 := ARRAY_JOIN(ARRAY('one'), ','),
-- Empty array returns NULL, as STRING_AGG over an empty set
f5 := ARRAY_JOIN(ARRAY()::ARRAY<VARCHAR>, ','),
-- NULL becomes empty string
f6 := ARRAY_JOIN(ARRAY('A', NULL::VARCHAR, 'C'), ','),
-- NULL replacement
f7 := ARRAY_JOIN(ARRAY('A', NULL::VARCHAR, 'C'), ',', 'empty'),
f8 := ZIP(ARRAY(',', ' | ') AS d).TRANSFORM(
RETURN ARRAY_JOIN(ARRAY('A', NULL::VARCHAR, 'C'), d)
).UNWRAP()
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR | f5 VARCHAR | f6 VARCHAR | f7 VARCHAR | f8 ARRAY |
|---|---|---|---|---|---|---|---|
| A, B, C | apple|banana|cherry | helloworld | one | NULL | A,C | A,empty,C | [A,C, A | C] |
On this page