In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to create hive partition, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The partitioning of HIVE is achieved by enabling partitionby when the table is created, and the dimension used for partition is not a column of the actual data, and the specific partition flag is given when the content is inserted. Where statement, which is similar to where tablename.partition_key > a, can be used to query the contents of a partition.
Create a table with partitions.
Command prototype:
CREATE TABLE page_view (viewTime INT, userid BIGINT
Page_urlSTRING, referrer_url STRING
Ip STRINGCOMMENT'IP Address of the User')
COMMENT 'This isthe page view table'
PARTITIONED BY (dtSTRING, country STRING)
CLUSTEREDBY (userid) SORTED BY (viewTime) INTO 32 BUCKETS
ROW FORMATDELIMITED
FIELDSTERMINATED BY'\ 001'
COLLECTION ITEMSTERMINATED BY'\ 002'
MAP KEYSTERMINATED BY'\ 003'
STORED ASSEQUENCEFILE
Eg:
Build a table:
CREATE TABLE c02_clickstat_fatdt1
(yyyymmdd string
Id INT
Ip string
Country string
Cookie_id string
Page_id string
Clickstat_url_id int
Query_string string
Refer string
) PARTITIONED BY (dt STRING)
Row format delimited fields terminated by'\ 005' stored astextfile
Load data:
LOAD DATA INPATH'/user/admin/SqlldrDat/CnClickstat/20101101/19/clickstat_gp_fatdt0/0' OVERWRITEINTO TABLE c02_clickstat_fatdt1
PARTITION (dt='20101101')
Access to a partition
SELECT count (*)
FROMc02_clickstat_fatdt1 a
WHERE a.dt > = '20101101' AND a.dt <' 20101102'
These are all the contents of the article "how to create partitions in hive". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.