Hive check elements in array

前端 未结 1 819
耶瑟儿~
耶瑟儿~ 2020-12-28 16:49

I have an Hive table made of user_id and item_id (id of items that have been purchased by the user). I want to get a list of all the users who purchased item 1 but not item

1条回答
  •  青春惊慌失措
    2020-12-28 17:08

    There are some collection functions in Hive `(See collection functions here : https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF ) which can use here.

    You can use the array_contains(Array, value) function to check if item 1 is present and the size(Array) function to make sure the length is 1. If both conditions are satisfied, you will get the desired output.

    0 讨论(0)
提交回复
热议问题