2 hive 函数

hive  wordcount

#####hive中的wordcount

# 原始数据  /opt/data/words.txt
# 创建表  
create table words(name string);
# 加载数据 
load data local inpath '/opt/data/words.txt' into table words;
# 查询表中的数据
select * from words;

 

 1.先spilt

 

 2. 炸裂explode

 

3. group by 统计

select 
wd,
count(*) num
from 
(select explode(split(name,',')) wd from words)t1
group by wd;

 

posted @ 2021-03-23 19:56  冰底熊  阅读(31)  评论(0)    收藏  举报