[英]Hive partition with wildcard
I am very new to partition. 我是分区的新手。
Suppose I have the following table 假设我有下表
table mytable(mytime timestamp, myname string) 表mytable(mytime时间戳,myname字符串)
where the column mytime is like this: year-month-day hour:min:sec.msec (for example,2014-12-05 08:55:59.3131) 其中mytime列是这样的:year-month-day hour:min:sec.msec(例如,2014-12-05 08:55:59.3131)
I want to partition mytable based on year-month-day of mytime 我想基于mytime的年-月-日对mytable进行分区
For example,I want to make a partition for 2014-12-05 例如,我想为2014-12-05分区
The record which has mytime like 2014-12-05 08:55:59,3131 will be in this partition. 我的时间为2014-12-05 08:55:59,3131的记录将位于此分区中。
So the query like select * from mytable where mytime='2014-12-05%'
will search the 因此,像
select * from mytable where mytime='2014-12-05%'
这样的查询select * from mytable where mytime='2014-12-05%'
将搜索
partition. 划分。
How can I do that in hive? 我该怎么做呢?
I already have data in mytable, do I need to recreate mytable and reload all the data? 我的mytable中已经有数据,是否需要重新创建mytable并重新加载所有数据?
Thank you 谢谢
input 输入
1997-12-31 23:59:59.999,kishore
2014-12-31 23:59:59.999999,manish
create table mytable_tmp(mytime string,myname string)
row format delimited
fields terminated by ',';
load data local inpath 'input.txt'
overwrite into table mytable_tmp;
create table mytable(myname string,mytimestamp string)
PARTITIONED BY (mydate string)
row format delimited
fields terminated by ',';
SET hive.exec.dynamic.partition = true;
SET hive.exec.dynamic.partition.mode = nonstrict;
INSERT OVERWRITE TABLE mytable PARTITION(mydate)
SELECT myname,mytime,to_date(mytime) from mytable_tmp;
select * from mytable where mydate='2014-12-31';
manish 2014-12-31 23:59:59.999999 2014-12-31
there is partition mydate which include myname and mytime according to your problem; 根据您的问题有mydate分区,其中包括myname和mytime;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.