ARRAY_CONTAINS verbose meanings in the hive

Is there a convenient way to use the ARRAY_CONTAINS function in the hive to search for multiple records in an array column, and not just one? Therefore, and not:

WHERE ARRAY_CONTAINS(array, val1) OR ARRAY_CONTAINS(array, val2)

I would like to write:

WHERE ARRAY_CONTAINS(array, val1, val2)

The complete problem is that I need to dynamically read val1both val2from the command line arguments when I run the script and I don’t know at all how many values ​​will be configured. Thus, you may think that valsis a comma separated list (or array) that contains the values of val1, val2, ...and I want to write

WHERE ARRAY_CONTAINS(array, vals)

Thanks in advance!

+3
source share
2 answers

UDF . ,

values_array = [val1, val2, ..., valn]

where array_intersection(array, values_array)[0] is not null

, [], [][0] null

+2

* () a arr, arr in (vals);

0

Source: https://habr.com/ru/post/1666188/


All Articles