SelectDB Cloud
SQL 手册
函数
array-functions
arrays_overlap

arrays_overlap

description

Syntax

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

判断left和right数组中是否包含公共元素。返回结果如下:

1    - left和right数组存在公共元素;
0    - left和right数组不存在公共元素;
NULL - left或者right数组为NULL;或者left和right数组中,任意元素为NULL;

notice

仅支持向量化引擎中使用

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

© 2023 北京飞轮数据科技有限公司 京ICP备2022004029号 | Apache、Apache Doris 以及相关开源项目名称均为 Apache 基金会商标