ARRAY_INTERSECT

All functions > ARRAY > ARRAY_INTERSECT

Returns the intersection of two arrays using set semantics.

Syntax

ARRAY_INTERSECT(array1, array2)
sql

Arguments

ParameterTypeRequiredDescription
array1ARRAYBIGINTYesThe first input array
array2ARRAYBIGINTYesThe second input array

Returns

An array containing the distinct elements that appear in both input arrays

Notes

  • Uses set semantics: duplicates in input arrays are removed
  • Returns only unique elements that exist in both arrays
  • Result is sorted lexicographically
  • Returns empty array if no common elements exist
  • Null arrays are treated as empty arrays

Examples

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