1 hive建表语句
create table table_name
(id string, name stirng, score double)
partitioned by (dt string)
STORED AS PARQUET TBLPROPERTIES('parquet.compression'='gzip');
2 hive导入数据
2.1 普通查询导入
insert into table my_table partition(dt='20210618')
select id,name,score from other_table where date_str='20210618'
2.2 hive导入数据-动态分区导入
-- 打开一些开关:动态分区开,非严格模式,动态分区数上限
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
SET hive.exec.max.dynamic.partitions=100000;
SET hive.exec.max.dynamic.partitions.pernode=100000;
insert into table my_table partition(dt)
select id,name,score,dt from other_table where dt>='20210601'
3 hive删减分区
ALTER TABLE table_Name DROP PARTITION (dt='20210618');