arrays_overlap function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns true if the intersection of array1 and array2 is not empty.

Syntax

arrays_overlap (array1, array2)

Arguments

  • array1: An ARRAY.
  • array2: An ARRAY sharing a least common type with array1.

Returns

In Databricks SQL, the result is the least common type of array1 and array2. In Databricks Runtime, the result is BOOLEAN true if there is overlap.

If the arrays have no common non-null element, they are both non-empty, and either of them contains a null element, NULL, false otherwise.

Examples

> SELECT arrays_overlap(array(1, 2, 3), array(3, 4, 5));
 true
> SELECT arrays_overlap(array(1, 2, NULL, 3), array(NULL, 4, 5));
 NULL