set  hive.exec.dynamic.partition.mode=nonstrict;
set  hive.exec.dynamic.partition=true;
set mapred.max.split.size=536870912;
set mapred.min.split.size.per.node=536870912;
set mapred.min.split.size.per.rack=536870912;
set mapreduce.map.memory.mb=4000;
set mapreduce.map.java.opts=-Xmx3000m;
set mapreduce.reduce.memory.mb=3072;
set mapreduce.reduce.java.opts=-Xmx2458m;
set hive.jobname.length=100;

insert into table dwh.dm_install_list_v2 partition(dt='${dt_today}',business='ali_activation')
     select device_id,'gaidmd5' device_type,'android' platform,'com.lazada.foractivation0922' package_name,'${update_date}' update_date
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20200912test' and device_type='testandroid'
     UNION
     select device_id,'idfamd5' device_type,'ios' platform,'2020092201' package_name,'${update_date}' update_date
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20200912test' and device_type='testios';


insert into table dwh.ods_dmp_user_info partition(dt='${dt_today}',business='ali_activation')
     select device_id,
     'gaidmd5' device_type,
     'android' platform,
     'ID' country,
     '' age,
     '' gender,
     '' tags,
     '${update_date}' first_req_day,
     '${update_date}' last_req_day
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20200912test' and device_type='testandroid'
     UNION
     select device_id,
     'idfamd5' device_type,
     'ios' platform,
     'ID' country,
     '' age,
     '' gender,
     '' tags,
     '${update_date}' first_req_day,
     '${update_date}' last_req_day
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20200912test' and device_type='testios';

insert into table dwh.dm_install_list_v2 partition(dt='${dt_today}',business='ali_activation')
     select device_id,'gaidmd5' device_type,'android' platform,'com.lazada.foractivation.buyer0929' package_name,'${update_date}' update_date
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20200912test' and device_type='buyer0929'
     UNION
     select device_id,'gaidmd5' device_type,'android' platform,'com.lazada.foractivation.nonbuyer0929' package_name,'${update_date}' update_date
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20200912test' and device_type='nonbuyer0929';

insert into table dwh.ods_dmp_user_info partition(dt='${dt_today}',business='ali_activation')
     select device_id,
     'gaidmd5' device_type,
     'android' platform,
     'ID' country,
     '' age,
     '' gender,
     '' tags,
     '${update_date}' first_req_day,
     '${update_date}' last_req_day
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20200912test' and device_type='buyer0929'
     UNION
     select device_id,
     'gaidmd5' device_type,
     'android' platform,
     'ID' country,
     '' age,
     '' gender,
     '' tags,
     '${update_date}' first_req_day,
     '${update_date}' last_req_day
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20200912test' and device_type='nonbuyer0929';


insert into table dwh.dm_install_list_v2 partition(dt='${dt_today}',business='ali_activation')
     select device_id,'gaidmd5' device_type,'android' platform,'com.lazada.foractivation.buyera1.1013' package_name,'${update_date}' update_date
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20201014' and device_type='buyerA1_1013';

insert into table dwh.ods_dmp_user_info partition(dt='${dt_today}',business='ali_activation')
     select device_id,
     'gaidmd5' device_type,
     'android' platform,
     'ID' country,
     '' age,
     '' gender,
     '' tags,
     '${update_date}' first_req_day,
     '${update_date}' last_req_day
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20201014' and device_type='buyerA1_1013';


insert into table dwh.dm_install_list_v2 partition(dt='${dt_today}',business='ali_activation')
     select device_id,'gaidmd5' device_type,'android' platform,'com.lazada.foractivation.buyera2-3.1013' package_name,'${update_date}' update_date
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20201014' and device_type='buyerA2-3_1013';

insert into table dwh.ods_dmp_user_info partition(dt='${dt_today}',business='ali_activation')
     select device_id,
     'gaidmd5' device_type,
     'android' platform,
     'ID' country,
     '' age,
     '' gender,
     '' tags,
     '${update_date}' first_req_day,
     '${update_date}' last_req_day
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20201014' and device_type='buyerA2-3_1013';

insert into table dwh.dm_install_list_v2 partition(dt='${dt_today}',business='ali_activation')
     select device_id,'gaidmd5' device_type,'android' platform,'com.lazada.foractivation.nonbuyera1.1013' package_name,'${update_date}' update_date
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20201014' and device_type='nonbuyerA1_1013';

insert into table dwh.ods_dmp_user_info partition(dt='${dt_today}',business='ali_activation')
     select device_id,
     'gaidmd5' device_type,
     'android' platform,
     'ID' country,
     '' age,
     '' gender,
     '' tags,
     '${update_date}' first_req_day,
     '${update_date}' last_req_day
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20201014' and device_type='nonbuyerA1_1013';

insert into table dwh.dm_install_list_v2 partition(dt='${dt_today}',business='ali_activation')
     select device_id,'gaidmd5' device_type,'android' platform,'com.lazada.foractivation.nonbuyera2-5.1013' package_name,'${update_date}' update_date
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20201014' and device_type='nonbuyerA2-5_1013';

insert into table dwh.ods_dmp_user_info partition(dt='${dt_today}',business='ali_activation')
     select device_id,
     'gaidmd5' device_type,
     'android' platform,
     'ID' country,
     '' age,
     '' gender,
     '' tags,
     '${update_date}' first_req_day,
     '${update_date}' last_req_day
     from dwh.dm_install_list_v2_tmp_deviceid where dt='20201014' and device_type='nonbuyerA2-5_1013';