append
On this page
Appends one element to an array.
Syntax
append(<array>, <value>)Arguments
| Argument | Type | Description |
|---|---|---|
<array> | array | Source array. |
<value> | Any type | Element to append. Its type may differ from existing elements; NULL is appended as an element. |
Returns
Returns array. Returns NULL if <array> is NULL.
Examples
Append a new label to each event while keeping its existing labels in order.
VALUES ('evt-17', ['checkout', 'timeout']), ('evt-42', [])
SELECT $0 AS event_id, $1 AS labels
SELECT event_id, append(labels, 'reviewed') AS labels+----------+-----------------------------------+
| event_id | labels |
+----------+-----------------------------------+
| evt-17 | ["checkout","timeout","reviewed"] |
| evt-42 | ["reviewed"] |
+----------+-----------------------------------+The expression returns a new array. Use dedup as a separate step if a label must appear only once.