ARRAY_EXCEPT

All functions > ARRAY > ARRAY_EXCEPT

Returns the difference of two arrays using set semantics.

Syntax

ARRAY_EXCEPT(array1, array2)
sql

Arguments

ParameterTypeRequiredDescription
array1ARRAYBIGINTYesThe source array from which elements will be removed
array2ARRAYBIGINTYesThe array containing elements to be removed from array1

Returns

An array containing elements from array1 that do not appear in array2

Notes

  • Uses set semantics: removes ALL occurrences of matching elements
  • Performs set subtraction (array1 - array2)
  • Result contains only unique elements from array1 not found in array2
  • Result is sorted lexicographically
  • Empty arrays are handled gracefully

Examples

Last update at: 2025/10/13 10:23:46