hive partition table

Suppose we have the data of the hotel for the past 10 years, the format is as follows


The meaning of each column
| hotel | | |
         | h_id | id |
| | h_region | Hotel administrative division |
| | h_hname | Hotel name | |
| h_address | | h_start | Open time | | | h_end | Check out | | | h_start_m | Open time timestamp | | | h_end_m | Check out time stamp | | | h_homecode | , No. 373, xx484 Road, Xiacheng District, Hangzhou, Name 65, U104, 2006/06/23 00:00:00, 2006/06/23 00:03:00, 1150992000000, 1150992180000, 495 2,8, Hotel 29, Hangzhou No. 927, xx866 Road, Yuhang District, City, Name 64, U193, 2006/06/24 00:00:00, 2006/06/24 00:16:00, 1151078400000, 1151079360000,376














3,8, Hotel 190, No. 801, xx81 Road, Yuhang District, Hangzhou City, Name 56, U149, 2006/06/24 00:00:00, 2006/06/24 00:10:00, 1151078400000, 1151079000000,67
4, 8, Hotel 771, No. 341, xx570 Road, Yuhang District, Hangzhou City, name 60, U870, 2006/06/25 00:00:00, 2006/06/25 00:06:00, 1151164800000, 1151165160000, 761
5,1, Hotel 584, No. 847, xx177 Road, Shangcheng District, Hangzhou, Name 13, U552, 2006/06/26 00:00:00, 2006/06/26 00:09:00, 1151251200000, 1151251740000, 583
6,5, Hotel 375 , No. 372, xx532 Road, Xihu District, Hangzhou, Name 93, U362, 2006/06/27 00:00:00, 2006/06/27
00:01:00, 1151337600000, 1151337660000, 470 410,1, Hotel 212, Hangzhou No. 444, xx67 Road, Shangcheng District, City, Name 35, U295, 2007/01/09 00:00:00, 2007/01/09 00:03:00, 1168272000000, 1168272180000,6
411,0, Hotel 732, Hangzhou Others No. 975, xx447 Road, District, Name 71, U546, 2007/01/09 00:00:00, 2007/01/09 00:09:00, 1168272000000, 1168272540000, 912
412,0, Hotel 502, other districts in Hangzhou xx700 No. 944 Road, Name 46, U580, 2007/01/09 00:00:00, 2007/01/09 00:01:00, 1168272000000, 1168272060000,742
413, 8, Hotel 907, No. 444, xx817 Road, Yuhang District, Hangzhou City, Name 60, U653, 2007/01/10 00:00:00, 2007/01/10 00:21:00, 1168358400000, 1168359660000, 629
414, 7, Hotel 426, No. 190, xx529 Road, Xiaoshan District, Hangzhou, Name 25, U425, 2007/01/11 00:00:00, 2007/01/11 00:16:00, 1168444800000, 1168445760000, 985
415,3, Hotel 227, No. 114, xx572 Road, Gongshu District, Hangzhou, Name 12, U453, 2007/01/11 00:00:00, 2007/01/11 00:11:00, 1168444800000, 1168445460000, 734
416,7, Hotel 804, No. 358, xx879 Road, Xiaoshan District, Hangzhou, Name 4, U234, 2007/01/11 00:00:00, 2007/01/11 00:12:00, 1168444800000, 1168445520000,156


create table hotel(
h_id bigint,
h_region string,
h_hname string,
h_address string,
h_uname string,
h_code string,
h_start string,
h_end string,
h_start_m bigint,
h_end_m bigint,
h_homecode string
)
partitioned by (ds string) row format delimited fields terminated by '\,' stored as textfile; 






load  data local inpath '/home/hadoop/data/hotel_data.txt' overwrite into table hotel partition (ds='2006-06');
load  data local inpath '/home/hadoop/data/hotel_data.txt' overwrite into table hotel partition (ds='2007-01');


select * from hotel where ds ='2006-06'; 
select * from hotel where ds ='2007-01'; 




load data local inpath '/home/hadoop/data/pro100000.txt' overwrite into table prob; 
load data local inpath '/home/hadoop/data/cate1000.txt' overwrite into table cateb; 






create table invites (id int, name string) partitioned by (ds string) row format delimited fields terminated by '\,'stored as textfile; 


load data local inpath '/home/hadoop/data/aa.txt' overwrite into table invites partition (ds='2013-08-16');


load data local inpath '/home/hadoop/data/a2.txt' overwrite into table invites partition (ds='2013-08-17'); 



hive (default)> select * from invites where ds ='2013-08-16'; 
OK
invites.id invites.name invites.ds
1 aa 2013-08-16
2 bb 2013-08-16
3 cc 2013-08-16
4 ee 2013-08-16
5 ff 2013-08-16
Time taken: 0.125 seconds, Fetched: 5 row(s)
hive (default)> select * from invites where ds ='2013-08-17';
OK
invites.id invites.name invites.ds
6 aa1 2013-08-17
7 bb2 2013-08-17
8 cc3 2013-08-17
9 ee4 2013-08-17
1 ff5 2013-08-17
Time taken: 0.084 seconds, Fetched: 5 row(s)
hive (default)> select * from invites ; 
OK
invites.id invites.name invites.ds
1 aa 2013-08-16
2 bb 2013-08-16
3 cc 2013-08-16
4 ee 2013-08-16
5 ff 2013-08-16
6 aa1 2013-08-17
7 bb2 2013-08-17
8 cc3 2013-08-17
9 ee4 2013-08-17
1 ff5 2013-08-17
Time taken: 0.055 seconds, Fetched: 10 row(s)
hive (default)> select * from invites where ds ='2013-08-12';  
OK
invites.id invites.name invites.ds
Time taken: 0.069 seconds







Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325761417&siteId=291194637