arrays_overlap

description

Syntax

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

Check if there is any common element for left and right array. Return below values:

  1. 1 - if any common element inside left and right array;
  2. 0 - if no common element inside left and right array;
  3. NULL - when left or right array is NULL; OR any element inside left and right array is NULL;

notice

Only supported in vectorized engine

example

  1. mysql> set enable_vectorized_engine=true;
  2. mysql> select c_left,c_right,arrays_overlap(c_left,c_right) from array_test;
  3. +--------------+-----------+-------------------------------------+
  4. | c_left | c_right | arrays_overlap(`c_left`, `c_right`) |
  5. +--------------+-----------+-------------------------------------+
  6. | [1, 2, 3] | [3, 4, 5] | 1 |
  7. | [1, 2, 3] | [5, 6] | 0 |
  8. | [1, 2, NULL] | [1] | NULL |
  9. | NULL | [1, 2] | NULL |
  10. | [1, 2, 3] | [1, 2] | 1 |
  11. +--------------+-----------+-------------------------------------+

keywords

ARRAY,ARRAYS,OVERLAP,ARRAYS_OVERLAP