码迷,mamicode.com
首页 > 其他好文 > 详细

Hive使用HDFS目录数据创建Hive表分区

时间:2014-12-22 18:02:19      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

描述:

Hive表pms.cross_sale_path建立以日期作为分区,将hdfs目录/user/pms/workspace/ouyangyewei/testUsertrack/job1Output/crossSale上的数据,写入该表的$yesterday分区上

表结构:

hive -e "
set mapred.job.queue.name=pms;

drop table if exists pms.cross_sale_path;
create external table pms.cross_sale_path
(
track_id string,
track_time string,
session_id string,
gu_id string,
end_user_id string,
page_category_id bigint,
algorithm_id int,
is_add_cart int,
rcmd_product_id bigint,
product_id bigint,
category_id bigint,
path_id string,
path_type int,
path_length int,
path_list string,
order_code string
)
PARTITIONED BY (ds string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' 
LINES TERMINATED BY '\n' 
STORED AS TEXTFILE;"

写法:

yesterday=`date -d -1days +%Y-%m-%d`
hive -e "load data inpath '/user/pms/workspace/ouyangyewei/testUsertrack/job1Output/crossSale' into table pms.cross_sale_path partition(ds='$yesterday');"

Hive使用HDFS目录数据创建Hive表分区

标签:

原文地址:http://blog.csdn.net/yeweiouyang/article/details/42082663

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!