Hive Create a Level two partition table.
1, create a level two partition table, by day, hour partition as an example
drop table Default.kwu_tracklog;
Create EXTERNAL Table Default.kwu_tracklog (
datetime string Comment "time: such as 2015-01-01 11:30:01:123",
IP string Co Mment "IP: User native IP or user's network segment external routing ip",
cookieid string Comment "User cookie: News unified unique Flag generated on the client",
userid string Comment " User and News Registration ID: User's Registration ID in and pick ",
Logserverip string comment Log server IP: Dispatch server IP",
referer string comment "source : User browsing the Web page refer ",
requesturl string comment" Access URL: Current Access url ",
remark1 string comment" temporarily useless ": the data is meaningless, due to early accession can not be removed" ,
Remark2 string comment "temporarily useless": this data is meaningless, due to early addition currently cannot be removed ",
alexaflag string comment" Alexa logo : This field is also early joined, When the user installs the Alexa tool The value is 1, otherwise 0. Early joins should have no meaning at present. ", UA
string comment" UA: User Browser ua ",
Wirelessflag string comment" Wireless Channel flag: A word for a wireless channel that indicates which channel the article corresponds to and "
comment "Browse trajectory log"
partitioned by (Day string Comment "partitioned table fields by Days", hour string Comment "Partitioned table fields by Hour")
ROW FORMAT delimited FIELDS terminated by '
STORED as textfile
location '/hdfs/hive/default/kwu_tracklog ';
2. Import data
Load data local inpath '/diskg/hexunlogs/tracklog_by5min/tracklog_10.0.121.74/20151014/2015101414*.dat ' overwrite into table Default.kwu_tracklog partition (day= ' 20151014 ', hour= ');
Load data local inpath '/diskg/hexunlogs/tracklog_by5min/tracklog_10.0.121.74/20151014/2015101415*.dat ' overwrite into table Default.kwu_tracklog partition (day= ' 20151014 ', hour= ' 15 ');
3, test the imported data
Select COUNT (*) from Default.kwu_tracklog where day= ' 20151014 ' and hour= ' limit 1;
Select COUNT (*) from Default.kwu_tracklog where day= ' 20151014 ' and hour= ' limit 1;