Skip to main content
Version: current [24.3.x]

ARRAY_REMOVE

Categories: Semi-Structured Data

ARRAY_REMOVE

Removes all elements that equal a given value from a list.

Syntax

ARRAY_REMOVE(list_column LIST, value any) → list

  • list_column: Column that contains a LIST expression. Cannot be an array literal.
  • value: An expression of any data type.

Examples

array_col contains ARRAY[1, 2, 3]
SELECT ARRAY_REMOVE(array_col, 1)
-- [2, 3]
array_col contains ARRAY[1,2,null]
SELECT ARRAY_REMOVE(array_col, 2)
-- [1,null]
array_col contains ARRAY[1,2,null]
SELECT ARRAY_REMOVE(array_col, null)
-- NULL
array_col contains ARRAY[null]
SELECT ARRAY_REMOVE(array_col, 2)
-- NULL
ARRAY_REMOVE example
SELECT ARRAY_REMOVE(null, 2)
-- NULL

Usage Notes

If the list is NULL, this function returns NULL. If the value is NULL, this function returns NULL.