ARRAY_APPEND

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Inserts a value at the end of an array.

Syntax 

1ARRAY_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.

1SELECT 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.

1SELECT 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 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!