hive partition insert时候设置动态分区

hive 种实现类似 这种 (hive中不支持)
insert overwrite table ******** partition(dt = date_add(’{date}’,3))
select

1 第一种方法
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table ts.dyy_test partition(dt)
select a,b,date_sub(‘2019-03-23’,2) dt from asdf.sldfjkskdjfllsjkkf
where dt=‘2019-03-15’;

2。第二种方法
set hive.exec.dynamic.partition.mode=nonstrict;

SET runmdt = date_sub(current_date,5);
INSERT OVERWRITE TABLE amobe_tbl PARTITION (create_dt)
SELECT
cal_id,caller_name,location,
h i v e c o n f : r u n m d t f r o m a m o b e t b l a W H E R E a . c r e a t e d t I N ( s e l e c t D I S T I N C T c r e a t e d t f r o m m t c a l l W H E R E c r e a t e d t b e t w e e n d a t e s u b ( c u r r e n t d a t e , 20 ) a n d c u r r e n t d a t e ) a n d a . c r e a t e d t = {hiveconf:runmdt} from amobe_tbl a WHERE a.create_dt IN ( select DISTINCT create_dt from mt_call WHERE create_dt between date_sub(current_date,20) and current_date) and a.create_dt= hiveconf:runmdtfromamobetblaWHEREa.createdtIN(selectDISTINCTcreatedtfrommtcallWHEREcreatedtbetweendatesub(currentdate,20)andcurrentdate)anda.createdt={hiveconf:runmdt};

参考:https://stackoverflow.com/questions/44886583/parameter-passing-to-partition-is-not-working-in-hive
和:https://www.cnblogs.com/amydi/p/10936204.html

你可能感兴趣的:(hive)