array_to_string
NULL array/delimiter return NULL. NULL elements are skipped unless non-NULL null_text is supplied.
Syntax
With null text (scalar)
- The optional third argument is available only with ARRAY_JOIN.
Array join default (scalar)
Arguments
Type notation used below:- T is the array element type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP or ARRAY.
With null text
Array join default
Returns
- Type: STRING
- Possible values: Joined text.
- NULL behavior: NULL array/delimiter return NULL. NULL elements are skipped unless non-NULL null_text is supplied.
Properties
Usage notes
- Nested arrays are traversed recursively.
- NULL replacement text behaves like an omitted replacement and skips NULL elements. Nested list elements are recursively joined in encounter order. Leaf types include strings, booleans, integers, FLOAT/DOUBLE and types convertible to STRING; other leaf types raise an error.
- INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
Examples
Alias calling form: ARRAY_JOIN
Join the values with a comma between them.
When the array contains NULL, omit those elements or supply replacement text:
Limitations
- Pass an ARRAY as the first argument. Reported VARCHAR widths do not limit or truncate the returned text.
- MAP and STRUCT elements are not supported.