Skip to main content
Converts each array element to its text representation, and concatenates those using an optional delimiter. If no delimiter is provided, an empty string is used instead. NULL array elements are omitted. Alias: ARRAY_JOIN

Syntax

ARRAY_TO_STRING(<array>[, <delimiter>])

Parameters

ParameterDescriptionSupported input types
<array>An array to be concatenatedARRAY
<delimiter>The delimiter used for concatenating the array elementsTEXT

Return Type

TEXT

Examples

In the example below, the three elements are concatenated with no delimiter.
SELECT ARRAY_TO_STRING(['1', '2', '3']) AS levels;
levels text
123

Rows: 1Execution time: 8.87ms

In this example, the levels are concatenated separated by a comma.
SELECT ARRAY_TO_STRING(['1', '2', '3'], ',') AS levels;
levels text
1,2,3

Rows: 1Execution time: 5.55ms

In this example, the elements of a nested array containing a NULL are concatenated.
SELECT ARRAY_TO_STRING([[1, 2], [3, 4], [NULL, 5]], ',') AS levels;
levels text
1,2,3,4,5

Rows: 1Execution time: 9.12ms