Skip to main content

arrays_overlap

arrays_overlap

Description

Syntax:

BOOLEAN arrays_overlap(ARRAY<T> left, ARRAY<T> right)

This function checks if there are any common elements in the left and right arrays. It returns one of the following results:

1    - there are common elements;
0 - there are no common elements;
NULL - the left or right array is NULL; or the left or right array contains NULL values;

Note:

It is only supported in vectorized engine.

Example

mysql> set enable_vectorized_engine=true;

mysql> select c_left,c_right,arrays_overlap(c_left,c_right) from array_test;
+--------------+-----------+-------------------------------------+
| c_left | c_right | arrays_overlap(`c_left`, `c_right`) |
+--------------+-----------+-------------------------------------+
| [1, 2, 3] | [3, 4, 5] | 1 |
| [1, 2, 3] | [5, 6] | 0 |
| [1, 2, NULL] | [1] | NULL |
| NULL | [1, 2] | NULL |
| [1, 2, 3] | [1, 2] | 1 |
+--------------+-----------+-------------------------------------+

Keywords

ARRAY,ARRAYS,OVERLAP,ARRAYS_OVERLAP