用hql来做wordcount
有以下文本文件:
hello tom hello jim hello rose hello tom tom love rose rose love jim jim love tom love is what what is love
需要用hive做wordcount
-- 建表映射
create table t_wc(sentence string);
-- 导入数据
load data local inpath '/root/hivetest/xx.txt' into table t_wc;
--hql:
SELECT word ,count(1) as cnts FROM ( SELECT explode(split(sentence, ' ')) AS word FROM t_wc ) tmp GROUP BY word order by cnts desc ;