-- All the elements in the array match the filter.
select array_filter([1,2,3],[1,1,1]);
+------------------------------------+
| array_filter([1, 2, 3], [1, 1, 1]) |
+------------------------------------+
| [1,2,3] |
+------------------------------------+
1 row in set (0.01 sec)
-- The filter is null and an empty array is returned.
select array_filter([1,2,3],null);
+-------------------------------+
| array_filter([1, 2, 3], NULL) |
+-------------------------------+
| [] |
+-------------------------------+
1 row in set (0.01 sec)
-- The input array is null, null is returned.
select array_filter(null,[1]);
+-------------------------+
| array_filter(NULL, [1]) |
+-------------------------+
| NULL |
+-------------------------+
-- Both the input array and filter are null. Null is returned.
select array_filter(null,null);
+--------------------------+
| array_filter(NULL, NULL) |
+--------------------------+
| NULL |
+--------------------------+
1 row in set (0.01 sec)
-- The filter contains a null element and an empty array is returned.
select array_filter([1,2,3],[null]);
+---------------------------------+
| array_filter([1, 2, 3], [NULL]) |
+---------------------------------+
| [] |
+---------------------------------+
1 row in set (0.01 sec)
-- The filter contains two null elements and an empty array is returned.
select array_filter([1,2,3],[null,null]);
+---------------------------------------+
| array_filter([1, 2, 3], [NULL, NULL]) |
+---------------------------------------+
| [] |
+---------------------------------------+
1 row in set (0.00 sec)
-- Only one element matches the filter.
select array_filter([1,2,3],[null,1,0]);
+---------------------------------------+
| array_filter([1, 2, 3], [NULL, 1, 0]) |
+---------------------------------------+
| [2] |
+---------------------------------------+
1 row in set (0.00 sec)