ARRAY_EXCEPT
All functions > ARRAY > ARRAY_EXCEPT
Returns the difference of two arrays using set semantics.
Syntax
ARRAY_EXCEPT(array1, array2)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
array1 | ARRAYBIGINT | Yes | The source array from which elements will be removed |
array2 | ARRAYBIGINT | Yes | The 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