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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值