hadoop hive 手记
1,创建表及分区,针对于squid_log
create table squid_tmp(visittime string, clientip string, visitdom string, visiturl string, visitstat string) partitioned by (pt_ip string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’ LINES TERMINATED BY ‘\n’ STORED AS TEXTFILE;
create table squid_tmpp(visittime string, clientip string, visitdom string, visiturl string, visitstat string) partitioned by (pt_ip string, pt_dt int) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’ LINES TERMINATED BY ‘\n’ STORED AS TEXTFILE;
create table squid_log
(visittime string, clientip string, visitdom string, visiturl string, visitstat string) partitioned by (pt_ip string, pt_dt int) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’ LINES TERMINATED BY ‘\n’ STORED AS TEXTFILE;
2, 导入文本到hive 中
load data local inpath ‘/data1/squid_log/117.34.80.249/tmp.log’ overwrite into table squid.squid_tmp partition(pt_ip = ‘117.34.80.249’)
3, 从 squid_tmp 导入到squid_log中
insert into table squid_log partition(pt_ip, pt_dt) select visittime, clientip, visitdom, visiturl, visitstat, substr(visittime,1,8) as pt_dt, pt_ip from squid_tmp;
4, hive 删除分区
alter table squid_log drop partition(pt_ip = ‘117.34.80.249’, pt_dt=20130224);
5, hive 查看分区信息
show partitions squid_log;
本文转自 swq499809608 51CTO博客,原文链接:http://blog.51cto.com/swq499809608/1142460
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/108002.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】:
Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】:
官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...