欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Hive创建动态分区

程序员文章站 2022-07-06 10:40:03
...
==================================dynamic.partition.  =====================================QQ438509676
set hive.exec.dynamic.partition=true;(可通过这个语句查看:set hive.exec.dynamic.partition;) 
set hive.exec.dynamic.partition.mode=nonstrict; 
SET hive.exec.max.dynamic.partitions=100000;(如果自动分区数大于这个参数,将会报错)
SET hive.exec.max.dynamic.partitions.pernode=100000;
================================== create    table     =====================================
Drop table table_name; --先删除表 没有则直接建表了
CREATE TABLE table_name    --创建表
(col1 string, col2 date, col3 double) 
partitioned by (datekey date)  --可以多个字段的组合分区 
 ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' Stored AS TEXTFILE;

================================== insert table partition=====================================

 

INSERT INTO TABLE table_Name

PARTITION (DateKey)

SELECT col1,col2,col3,DateKey FROM otherTable

WHERE DATEKEY IN ('2017-02-26','2013-06-12','2013-09-24')

GROUP BY col1,col2,col3,DateKey  

DISTRIBUTE BY DateKey

================================== delete table partition=====================================

ALTER TABLE table_Name DROP PARTITION (Datekey='2016-05-05');

相关标签: Hive