Syntax

    1. mysql> set enable_vectorized_engine=true;
    2. mysql> select k1,k2,k3,array_intersect(k2,k3) from array_type_table;
    3. +------+-----------------+--------------+-----------------------------+
    4. | k1 | k2 | k3 | array_intersect(`k2`, `k3`) |
    5. +------+-----------------+--------------+-----------------------------+
    6. | 1 | [1, 2, 3] | [2, 4, 5] | [2] |
    7. | 2 | [2, 3] | [1, 5] | [] |
    8. +------+-----------------+--------------+-----------------------------+
    9. mysql> select k1,k2,k3,array_intersect(k2,k3) from array_type_table_nullable;
    10. | k1 | k2 | k3 | array_intersect(`k2`, `k3`) |
    11. +------+-----------------+--------------+-----------------------------+
    12. | 1 | [1, NULL, 3] | [1, 3, 5] | [1, 3] |
    13. | 2 | [NULL, NULL, 2] | [2, NULL, 4] | [NULL, 2] |
    14. | 3 | NULL | [1, 2, 3] | NULL |
    15. +------+-----------------+--------------+-----------------------------+
    16. mysql> select k1,k2,k3,array_intersect(k2,k3) from array_type_table_varchar;
    17. +------+----------------------------+----------------------------------+-----------------------------+
    18. +------+----------------------------+----------------------------------+-----------------------------+
    19. | 1 | ['hello', 'world', 'c++'] | ['I', 'am', 'c++'] | ['c++'] |
    20. | 3 | ['hasnull', NULL, 'value'] | ['nohasnull', 'nonull', 'value'] | [NULL, 'value'] |
    21. | 3 | ['hasnull', NULL, 'value'] | ['hasnull', NULL, 'value'] | ['hasnull', 'value'] |
    22. +------+----------------------------+----------------------------------+-----------------------------+
    23. mysql> select k1,k2,k3,array_intersect(k2,k3) from array_type_table_decimal;
    24. +------+------------------+-------------------+-----------------------------+
    25. | k1 | k2 | k3 | array_intersect(`k2`, `k3`) |
    26. +------+------------------+-------------------+-----------------------------+
    27. | 1 | [1.1, 2.1, 3.44] | [2.1, 3.4, 5.4] | [2.1] |
    28. | 2 | [NULL, 2, 5] | [NULL, NULL, 5.4] | [NULL] |
    29. +------+------------------+-------------------+-----------------------------+