Hive wordcunt

本文介绍了如何使用Hive进行单词统计。首先创建数据表并导入数据,然后通过split和explode函数拆分单词,接着创建结果表并利用group by与count统计每个单词的数量。最后展示了查询基站掉话率的相关操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

单词统计:
数据:
hello hello word
hello wc wc wc
bye bye
hello word
hello nihao chaina

创建数据表:(只有一个列不需要row format)

create table wc (
line string
);

放入数据:

load data local inpath '/root/table/wc' into table wc;

分析:使用 ’ '空格切割成数组,在嵌套explode( )进行拆分,每个参数成为一列;
select explode(split(line, ’ ')) as word from wc;

创建结果表:(word用来存放单词,ct用来存放出现的个数)

create table wcjg(
word string,
ct int
);

放入数据:group by 集合函数 count单词数量

from (select explode(split(line, ' ')) as word from wc)  tmp
insert into table wcjg
select word , count(word) as ct  group by word; 

查询数据:

select * from wcjg;

基站掉话率:
数据表:

create table cell_monitor(
record_time string,
imei string,
cell string,
ph_num int,
call_num int,
drop_num int,
duration int,
drop_rate double,
net_type string
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值