数据如下:
废话不多说,开干
1、将数据上传至hdfs。
2、建立原始数据表:
create table phone_raw
(
record_time String,
imei String,
cell String,
ph_num int,
call_num int,
drop_num int,
duration int,
drop_rate int,
net_type String,
erl int
)
row format delimited
fields terminated by ',' #####注意分割符
lines terminated by '\n';
3、将数据导入原始数据表中:
hive> load data local inpath '/root/user.tmp/phone.csv' into table phone_raw;
Loading data to table default.phone_raw
OK
Time taken: 1.225 seconds
4、查看原始数据表
5、创建结果表
create table phone_result
(
imei String,
drop_num int,
duration int,
drop_rate double
)
row format delimited
fields terminated by ','
lines terminated by '\n';
6、分析计算并将数据导入结果表
hive> insert into phone_result
>s