Hive Create level two partition table _hive

Source: Internet
Author: User

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;



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.