Checks whether Array a contains Element v.

Syntax

boolean array_contains(array<T> <a>, value <v>)

Parameters

  • a: required. This parameter specifies an array that T in array<T> specifies the data type of the elements in the array. The elements can be of any data type.
  • v: required. This parameter specifies the element that you want to check. The value of v must be of the same data type as the elements in Array a.

Return value

A value of the BOOLEAN type is returned.

Examples

The t_table_array table contains thec1 (BIGINT) and t_array (ARRAY<STRING>) fields. Data in the table:
+------------+---------+
| c1         | t_array |
+------------+---------+
| 1000       | [k11, 86, k21, 15] |
| 1001       | [k12, 97, k22, 2] |
| 1002       | [k13, 99, k23, 1] |
+------------+---------+
Sample statement:
-- Check whether the t_array column contains the value 1. 
select c1, array_contains(t_array,'1') from t_table_array;
-- The following result is returned: 
+------------+------+
| c1         | _c1  |
+------------+------+
| 1000       | false |
| 1001       | false |
| 1002       | true |
+------------+------+