I am trying to perform a version of the word count function in Hive. Ii have the following fields: Owner_key and Post. I want to split the post into its individual words and then group by each UserId along with giving a count of each word. For example, say if this was my data:
|1||apple orange apple|
I would like the following output:
The code I have attempted is below. Hive is not necessarily giving me an error message; however it never shows me any results even when the status is at 100%.
Can anyone help?
Thanks in advance.
SELECT owner_key, word, count(*)FROM stackdata_updtd LATERAL VIEW explode(split(lower(post), '\\W+')) t1 AS word GROUP BY owner_key, word;