ARRAY_APPEND

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Inserts a value at the end of an array.

Syntax

array_append(<array>, <value>)

Arguments

Required

  • <array>: The array to append to.
  • <value>: The value to insert at the end. The value must be NULL or match array element type, otherwise your SQL query will fail. Appending NULL changes the array element type to nullable.

Returns

Returns an array with the new value inserted at the end.

Examples

Append a Value

Add a value to the end of an array.

SELECT array_append(array[1, 2, 3], 4) AS result;

Returns array[1, 2, 3, 4], with 4 added at the end.

Append NULL

Add a NULL value to the end of an array.

SELECT array_append(array[1, 2, 3], null) AS result;

Returns array[1, 2, 3, null]. Appending NULL to an array with a non-nullable element type changes the resulting element type to nullable.

Related Documentation