一、杀死正在跑的任务
yarn application -kill application_XXXX
二、hive动态分区
1、设置两个参数值
set hive.exec.dynamic.partition =true;
set hive.exec.dynamic.partition.mode = nonstrict;
2、语句
建表语句(与正常建表语句没有区别)
create table hw_1_zyjk_qwsjxygj_101.jk_ld_ms_xw_model_60001_1122
(
msisdn string,
age string,
edu_degr_cd string,
halt_con_new string,
halt_day_con string,
innet_months string,
is_bnd_pay string,
is_open_gj_ct string,
is_open_gj_my string,
reg_no string,
subs_stat_typ_cd string
)
partitioned by(stat_month string)
row format delimited fields terminated by '\t' ;
#添加一个列
alter table jk_ld_ms_xw_model_60001_1122 add columns(bank_id string);
插入数据
insert overwrite table hw_1_zyjk_qwsjxygj_101.jk_ld_ms_xw_model_60001_1122 partition (stat_month)
select t.msisdn,t.age,t.edu_degr_cd,t.halt_con_new,t.halt_day_con,t.innet_months,t.is_bnd_pay,t.is_open_gj_ct,t.is_open_gj_my,t.reg_no,t.subs_stat_typ_cd,t.bank_id,t.target_mon from
(
select
a.msisdn,
substr(CURRENT_DATE,0,4) - substr(a.idty_bth_dt,0,4) as age,
a.edu_degr_cd,
a.halt_con_new,
a.halt_day_con,
a.floor(months_between(CURRENT_DATE,from_unixtime(unix_timestamp(ent_dt,'yyyymmdd'),'yyyy-mm-dd'))) as innet_months,
a.is_bnd_pay,
a.is_open_gj_ct,
a.is_open_gj_my,
a.reg_no,
a.subs_stat_typ_cd,
b.bank_id,
a.target_mon as stat_month
from
(select * from zh1_hw_qwsjuser.60001_xyf_user_info_fig_m)a
inner join
(select msisdn_sm4,bank_id,target_mon from msnxw_labels_0806_sm4)b
on a.statis_mon=b.target_mon and a.msisdn=b.msisdn_sm4
) t;
与静态分区的不同点:
- partition (stat_month)
- 动态分区字段放在最后
三、給某表添加列,给某表改名
alter table jk_ld_ms_xw_model_60001_1122 add columns(bank_id string);
alter table 原表名 rename to 新表名;