new file: 01 dm_tf_external_sales.sql

new file:   02 dm_td_external_keycompatitor.sql
	new file:   03 dm_td_external_brand_market.sql
	new file:   04 dm_td_external_calendar.sql
	new file:   05 dm_td_external_exchangerate.sql
	new file:   07 dm_td_external_packinfo.sql
	new file:   08 dm_td_external_corp.sql
	new file:   09 dm_td_external_geo_type.sql
	new file:   11 DM_TD_EXTERNAL_MARKET_NEW.sql
	new file:   12 dm_td_external_org.sql
	new file:   13 external auth.sql
	new file:   14 dm_tf_external_retail_special_bkp.sql
	new file:   AIA/01 dm_aia_pack_property.sql
	new file:   AIA/02 dm_ext_aia_sales.sql
	new file:   AIA/02 dm_ext_aia_sales_bakup_20230327.sql
	new file:   AIA/03 dm_aia_flag.sql
	new file:   AIA/04 dm_aia_provided_flag.sql
	new file:   AIA/06 DM_TD_EXT_AIA_PACK_PROPERTY.sql
	new file:   AIA/07 DM_TD_EXT_AIA_PACK2MARKET.sql
	new file:   AIA/08 DM_TD_EXT_AIA_MARKET_RATIO.sql
	new file:   AIA/09 DM_TD_EXT_AIA_MARKET_BRAND_RATIO.sql
	new file:   AIA/10 DM_TD_EXT_AIA_MARKET_PACK_MAPPING.sql
	new file:   AIA/11 DM_TD_EXT_AIA_TARGET_INST.sql
	new file:   AIA/11 dm_aia_targethp_flag.sql
	new file:   "AIA/z_03 dm_aia_flag_\345\244\207\344\273\275\347\224\250.sql"
	new file:   CHC/01 dm_chc_pack_property.sql
	new file:   CHC/02 DM_TF_EXT_CHC_SALES.sql
	new file:   CHC/03 DM_TD_EXT_CHC_PACK_PROPERTY.sql
	new file:   CHC/04 DM_TD_EXT_CHC_PACK2MARKET.sql
	new file:   CHC/05 DM_TD_EXT_CHC_MARKET_RATIO.sql
	new file:   CHC/06 DM_TD_EXT_CHC_MARKET_BRAND_RATIO.sql
	new file:   CHC/07 DM_TD_EXT_CHC_MARKET_PACK_MAPPING.sql
	new file:   CHPA/01 dwd_ims_atc_hierarchy.sql
	new file:   CHPA/01 dwd_ims_nfc_hierarchy.sql
	new file:   CHPA/01 dwd_ims_td_manufacturer_corp.sql
	new file:   CHPA/01 dwd_ims_td_pack_property.sql
	new file:   CHPA/01 dwd_update.sql
	new file:   CHPA/01_FB_BLOB_TO_DWD.sql
	new file:   CHPA/02 DWS_IMS_TD_GEO.sql
	new file:   CHPA/02 dws_ims_td_atc_cn.sql
	new file:   CHPA/02 dws_ims_td_corp_cn.sql
	new file:   CHPA/02 dws_ims_td_date.sql
	new file:   CHPA/02 dws_ims_td_manu_cn.sql
	new file:   CHPA/02 dws_ims_td_market.sql
	new file:   CHPA/02 dws_ims_td_market_ta.sql
	new file:   CHPA/02 dws_ims_td_nfc_cn.sql
	new file:   CHPA/02 dws_ims_td_prod_cn.sql
	new file:   CHPA/02 tmp_ims_td_prod_tmp.sql
	new file:   CHPA/02 tmp_ims_tf_fact_sales.sql
	new file:   CHPA/03 DM_TD_EXT_CHPA_MARKET_BRAND_RATIO.sql
	new file:   CHPA/03 DM_TD_EXT_CHPA_MARKET_PACK_MAPPING.sql
	new file:   CHPA/03 DM_TD_EXT_CHPA_MARKET_RATIO.sql
	new file:   CHPA/03 DM_TD_EXT_CHPA_PACK2MARKET.sql
	new file:   CHPA/03 DM_TD_EXT_CHPA_PACK_PROPERTY.sql
	new file:   CHPA/03 DM_TF_EXT_CHPA_SALES.sql
	new file:   CHPA/03 dm_ims_td_calendar.sql
	new file:   CHPA/03 dm_ims_td_geo.sql
	new file:   CHPA/03 dm_ims_td_market_property.sql
	new file:   CHPA/03 dm_ims_td_org.sql
	new file:   CHPA/03 dm_ims_td_org_hvh.sql
	new file:   CHPA/03 dm_ims_td_pack_property.sql
	new file:   CHPA/03 dm_ims_tf_sales.sql
	new file:   CHPA/03 dm_td_chpa_market_definition.sql
	new file:   CHPA/03 dm_td_ims_city_mapping.sql
	new file:   EC/03 ec_load_data.sql
	new file:   EC/04 DM_TD_EXT_EC_PACK_PROPERTY.sql
	new file:   EC/05 DM_TF_EXT_EC_SALES.sql
	new file:   EC/06 DM_TD_EXT_EC_PACK2MARKET.sql
	new file:   EC/07 DM_TD_EXT_EC_MARKET_RATIO.sql
	new file:   EC/08 DM_TD_EXT_EC_MARKET_BRAND_RATIO.sql
	new file:   EC/09 DM_TD_EXT_EC_MARKET_PACK_MAPPING.sql
	new file:   EC/1 (ec)blob_to_dwd.sql
	new file:   EC/2 dwd_inc_gnd_ext_ec_nationnal_pack_union_all.py
	new file:   Merged_Data/Merged_Data_Config_table_bkp.sql
	new file:   Merged_Data/Merged_Data_Config_table_bymonth.sql
	new file:   Merged_Data/dm_tf_exteranl_sales_merged_data_dtp_others_bkp.sql
	new file:   Merged_Data/dm_tf_exteranl_sales_merged_data_dtp_others_bymonth_bkp.sql
	new file:   ORG/DM_TD_EXT_AIA_ORG.sql
	new file:   ORG/DM_TD_EXT_CHC_ORG.sql
	new file:   ORG/DM_TD_EXT_CHPA_ORG.sql
	new file:   ORG/DM_TD_EXT_COUNTY_ORG.sql
	new file:   ORG/DM_TD_EXT_EC_ORG.sql
	new file:   ORG/DM_TD_EXT_RETAIL_ORG.sql
	new file:   ORG/DM_TD_EXT_THC_ORG.sql
	new file:   ORG/DM_TD_EXT_XIEHE_ORG.sql
	new file:   OTHERS/01 dm_td_report_url.sql
	new file:   OTHERS/02 dws_ext_email_warning.sql
	new file:   OTHERS/external_triggered_email.py
	new file:   Retail/01 load_tmp_data.py
	new file:   Retail/02 split_brand_data.py
	new file:   Retail/03 split_pack_data.py
	new file:   Retail/04 map_to_dws_table.py
	new file:   Retail/05 load_dtp_temp_data.py
	new file:   Retail/06 split_dtp_brand_data.py
	new file:   Retail/07 split_dtp_pack_data.py
	new file:   Retail/08 map_to_dtp_dws_table.py
	new file:   Retail/09 dwd_inc_gnd_ext_retail_nataional.py
	new file:   Retail/10 map_to_retail_dm_table.py
	new file:   Retail/11 map_to_overview_dm_table.py
	new file:   Retail/12 dws_tf_external_retail_dtp_special.sql
	new file:   Retail/13 DM_TF_EXT_RETAIL_SALES.sql
	new file:   Retail/14 DM_TF_EXT_RETAIL_DTP_SALES.sql
	new file:   Retail/15 DM_TD_EXT_RETAIL_PACK_PROPERTY.sql
	new file:   Retail/16 DM_TD_EXT_RETAIL_DTP_PACK_PROPERTY.sql
	new file:   Retail/17 DM_TD_EXT_DTP_PACK2MARKET.sql
	new file:   Retail/17 DM_TD_EXT_RETAIL_PACK2MARKET.sql
	new file:   Retail/18 DM_TD_EXT_DTP_MARKET_RATIO.sql
	new file:   Retail/18 DM_TD_EXT_RETAIL_MARKET_RATIO.sql
	new file:   Retail/19 DM_TD_EXT_DTP_MARKET_BRAND_RATIO.sql
	new file:   Retail/19 DM_TD_EXT_RETAIL_MARKET_BRAND_RATIO.sql
	new file:   Retail/20 DM_TD_EXT_DTP_MARKET_PACK_MAPPING.sql
	new file:   Retail/20 DM_TD_EXT_RETAIL_MARKET_PACK_MAPPING.sql
	new file:   "Retail/z1 dwd_inc_gnd_ext_retail_nataional_\344\275\234\345\272\237.py"
	new file:   "Retail/z2 retail_load_data_\344\275\234\345\272\237.sql"
	new file:   "Retail/z3 retail_overview_data_\344\275\234\345\272\237.sql"
	new file:   THC/01 dm_thc_pack_property.sql
	new file:   THC/02 dm_ext_thc_sales.sql
	new file:   THC/02 dm_ext_thc_sales_bakup_20260327.sql
	new file:   THC/03 DM_TF_EXT_THC_MARKET_SALES_CHT.sql
	new file:   THC/04 dm_tf_external_sales_thc.sql
	new file:   THC/05 DM_TD_EXT_THC_PACK_PROPERTY.sql
	new file:   THC/06 DM_TD_EXT_THC_PACK2MARKET.sql
	new file:   THC/07 DM_TD_EXT_THC_MARKET_RATIO.sql
	new file:   THC/08 DM_TD_EXT_THC_MARKET_BRAND_RATIO.sql
	new file:   THC/09 DM_TD_EXT_THC_MARKET_PACK_MAPPING.sql
	new file:   UNIONALL/DM_TD_EXT_UNIONALL_MARKET_PACK_MAPPING.sql
	new file:   UNIONALL/DM_TD_EXT_UNIONALL_PACKINFO.sql
	new file:   UNIONALL/DM_TF_EXT_UNIONALL_MARKET_SALES.sql
	new file:   UNIONALL/DM_TF_EXT_UNIONALL_MARKET_SALES_v1.0.sql
	new file:   UNIONALL/DM_TF_EXT_UNIONALL_SALES.sql
	new file:   UNIONALL/DM_TF_EXT_UNIONALL_SALES_MAPPING.sql
	new file:   UNIONALL/DM_TF_EXT_UNIONALL_SALES_MAPPING_NIAD.sql
	new file:   XIEHE/01 xiehe_blob_to_dwd.py
	new file:   XIEHE/02 dm_xiehe_pack_property.sql
	new file:   XIEHE/03 dm_ext_xiehe_geo.sql
	new file:   XIEHE/04 dm_ext_xiehe_sales.sql
	new file:   XIEHE/05 dm_td_xiehe_core_dept.sql
	new file:   XIEHE/06 DM_TF_EXT_XIEHE_SALES.sql
	new file:   XIEHE/07 DM_TD_EXT_XIEHE_PACK_PROPERTY.sql
	new file:   XIEHE/08 DM_TD_EXT_XIEHE_PACK2MARKET.sql
	new file:   XIEHE/09 DM_TD_EXT_XIEHE_MARKET_RATIO.sql
	new file:   XIEHE/10 DM_TD_EXT_XIEHE_MARKET_BRAND_RATIO.sql
	new file:   XIEHE/11 DM_TD_EXT_XIEHE_MARKET_PACK_MAPPING.sql
	new file:   XIEHE/bkp_01 xiehe_blob2dwd.py
	new file:   XIEHE/bkp_02 dm_ext_xiehe_sales.sql
	new file:   XIEHE/bkp_03 dm_ext_xiehe_pack_property.sql
	new file:   county/01 tmp_ims_county_fact_sales_sum.sql
	new file:   county/02 tmp_imscounty_Result.sql
	new file:   county/03 dm_ims_td_county_geo.sql
	new file:   county/04 dws_ext_county_tf_sales.sql
	new file:   county/05 dm_ext_county_td_pack_property.sql
	new file:   county/06 dm_td_county_pack_region.sql
	new file:   county/07 dm_ext_county_tf_sales_region.sql
	new file:   county/08 DM_TD_EXT_COUNTY_PACK_PROPERTY.sql
	new file:   county/09 DM_TF_EXT_COUNTY_SALES.sql
	new file:   county/10 DM_TD_EXT_COUNTY_PACK2MARKET.sql
	new file:   county/11 DM_TD_EXT_COUNTY_MARKET_RATIO.sql
	new file:   county/12 DM_TD_EXT_COUNTY_MARKET_BRAND_RATIO.sql
	new file:   county/13 DM_TD_EXT_COUNTY_MARKET_PACK_MAPPING.sql
	new file:   for_AIA_Dashboard/01 dm_td_aia_inst_mkt.sql
	new file:   for_AIA_Dashboard/02 dm_td_aia_auth_sales.sql
	new file:   for_AIA_Dashboard/03 dm_td_aia_original_col.sql
	new file:   for_AIA_Dashboard/04 dm_td_aia_nosales_inst.sql
	new file:   for_AIA_Dashboard/05 dm_td_aia_is_eagle_flag.sql
	new file:   for_AIA_Dashboard/06 dm_td_aia_rank.sql
	new file:   for_AIA_Dashboard/07 dm_ext_aia_data_remove_flag.sql
	new file:   for_AIA_Dashboard/07 dm_td_aia_remove_special_ins_bkp.py
	new file:   for_AIA_Dashboard/08 dm_ext_aia_data_quality_flag.sql
	new file:   z 01 dm_tf_external_sales.sql
	new file:   "z 10 dm_td_external_market_pack_mapping_\344\275\234\345\272\237.sql"
	new file:   "z 11 dm_td_external_market_\344\275\234\345\272\237.sql"
	new file:   "\344\270\212\347\272\277\350\204\232\346\234\254.sql"
	new file:   "\346\225\260\346\215\256\351\252\214\350\257\201.sql"
This commit is contained in:
2026-04-27 15:48:38 +08:00
parent d2485035c0
commit 832c7bcd69
173 changed files with 62579 additions and 0 deletions

View File

@@ -0,0 +1,238 @@
-- Databricks notebook source
-- 20260119 依赖上面 dwd.dwd_ims_td_pack_property
-- 20260119 依赖上面补0 dwd.dwd_ims_td_pack_property dwd.dwd_gnd_ims_tblmarket
-----MARKET
--
-- Extend_Market NOT_IN_FLAG
insert overwrite table tmp.tmp_ims_td_temp_market
select distinct t2.market,t1.*,
t2.bu,CASE WHEN t2.extend_market_ratio IS NULL THEN '1' ELSE t2.extend_market_ratio END AS Market_Ratio
from dwd.dwd_ims_td_pack_property t1
left join (select * from dwd.dwd_gnd_ims_tblmarket WHERE Extend_Market IS NULL AND ( NOT_IN_FLAG IS NULL or NOT_IN_FLAG = '1' )) t2
on t1.ATC1_COD = case when t2.ATC1_Code is null then t1.ATC1_COD else t2.ATC1_Code end
and t1.ATC2_COD = case when t2.ATC2_Code is null then t1.ATC2_COD else t2.ATC2_Code end
and t1.ATC3_COD = case when t2.ATC3_Code is null then t1.ATC3_COD else t2.ATC3_Code end
and t1.ATC4_COD = case when t2.ATC4_Code is null then t1.ATC4_COD else t2.ATC4_Code end
and t1.APP1_COD = case when t2.NFC1_Code is null then t1.APP1_COD else t2.NFC1_Code end
and t1.APP2_COD = case when t2.NFC2_Code is null then t1.APP2_COD else t2.NFC2_Code end
and t1.APP3_COD = case when t2.NFC3_Code is null then t1.APP3_COD else t2.NFC3_Code end
and t1.CORP_COD = case when t2.corporation_code is null then t1.CORP_COD else t2.corporation_code end
and t1.MANU_COD = case when t2.Manufacturer_Code is null then t1.MANU_COD else t2.Manufacturer_Code end
and t1.PROD_COD = case when t2.Product_Code is null then t1.PROD_COD else t2.Product_Code end
and t1.PACK_COD = case when t2.Pack_Code is null then t1.PACK_COD else t2.Pack_Code end
and t1.STGH_DES = case when t2.Strength is null then t1.STGH_DES else t2.Strength end
and t1.CMPS_COD = case when t2.Molecule_Code is null then t1.CMPS_COD else t2.Molecule_Code end
where t2.market is not null
;
-- COMMAND ----------
--
-- Extend_Market NOT_IN_FLAG
insert overwrite table tmp.tmp_ims_td_temp_market_del
select distinct t2.market,t1.*,t2.bu,CASE WHEN t2.extend_market_ratio IS NULL THEN '1' ELSE t2.extend_market_ratio END AS Market_Ratio
from dwd.dwd_ims_td_pack_property t1
left join (select * from dwd.dwd_gnd_ims_tblmarket WHERE Extend_Market IS NULL AND NOT_IN_FLAG = '0' ) t2
on t1.ATC1_COD = case when t2.ATC1_Code is null then t1.ATC1_COD else t2.ATC1_Code end
and t1.ATC2_COD = case when t2.ATC2_Code is null then t1.ATC2_COD else t2.ATC2_Code end
and t1.ATC3_COD = case when t2.ATC3_Code is null then t1.ATC3_COD else t2.ATC3_Code end
and t1.ATC4_COD = case when t2.ATC4_Code is null then t1.ATC4_COD else t2.ATC4_Code end
and t1.APP1_COD = case when t2.NFC1_Code is null then t1.APP1_COD else t2.NFC1_Code end
and t1.APP2_COD = case when t2.NFC2_Code is null then t1.APP2_COD else t2.NFC2_Code end
and t1.APP3_COD = case when t2.NFC3_Code is null then t1.APP3_COD else t2.NFC3_Code end
and t1.CORP_COD = case when t2.corporation_code is null then t1.CORP_COD else t2.corporation_code end
and t1.MANU_COD = case when t2.Manufacturer_Code is null then t1.MANU_COD else t2.Manufacturer_Code end
and t1.PROD_COD = case when t2.Product_Code is null then t1.PROD_COD else t2.Product_Code end
and t1.PACK_COD = case when t2.Pack_Code is null then t1.PACK_COD else t2.Pack_Code end
and t1.STGH_DES = case when t2.Strength is null then t1.STGH_DES else t2.Strength end
and t1.CMPS_COD = case when t2.Molecule_Code is null then t1.CMPS_COD else t2.Molecule_Code end
where t2.market is not null
;
-- COMMAND ----------
--TempMKT中删除数据
--TempMKT的字段结构Value里面放个空值
MERGE INTO tmp.tmp_ims_td_temp_market AS t1
USING tmp.tmp_ims_td_temp_market_del AS t2
on t1.ATC1_COD = t2.ATC1_COD
and t1.ATC2_COD = t2.ATC2_COD
and t1.ATC3_COD = t2.ATC3_COD
and t1.ATC4_COD = t2.ATC4_COD
and t1.APP1_COD = t2.APP1_COD
and t1.APP2_COD = t2.APP2_COD
and t1.APP3_COD = t2.APP3_COD
and t1.CORP_COD = t2.CORP_COD
and t1.MANU_COD = t2.MANU_COD
and t1.PROD_COD = t2.PROD_COD
and t1.PACK_COD = t2.PACK_COD
and t1.STGH_DES = t2.STGH_DES
and t1.CMPS_COD = t2.CMPS_COD
and t1.market = t2.market
WHEN MATCHED THEN DELETE
;
-- COMMAND ----------
---
-- Extend_Market
insert into tmp.tmp_ims_td_temp_market
select distinct
t2.Market,
t1.PACK_COD ,
t1.PACK_DES ,
t1.STGH_DES ,
t1.PACK_LCH ,
t1.PROD_COD ,
t1.CMPS_COD ,
t1.CMPS_DES ,
t1.ATC1_COD ,
t1.ATC2_COD ,
t1.ATC3_COD ,
t1.ATC4_COD ,
t1.APP1_COD ,
t1.APP2_COD ,
t1.APP3_COD ,
t1.BIO_DESC ,
t1.GENE_ORIG_DESC ,
t1.ETH_OTC_DESC ,
t1.NRDL_DESC ,
t1.NRDL_Entry_Date ,
t1.EDL_DESC ,
t1.TCM_DESC ,
t1.PAED_DESC ,
t1.GQCE_DESC ,
t1.VBP_DESC ,
t1.MANU_COD ,
t1.MANU_DES ,
t1.MNFL_COD ,
t1.MNFL_DES ,
t1.CORP_COD ,
t1.CORP_DES ,
t2.BU,
t1.BrandType ,
case when t2.Extend_Market_Ratio is null then '1' end AS Market_Ratio--1
from tmp.tmp_ims_td_temp_market t1
left join (select Market, BU,Extend_Market,Extend_Market_Ratio from dwd.dwd_gnd_ims_tblmarket WHERE Extend_Market IS NOT NULL) t2 on t1.Market=t2.Extend_Market
where t2.Market is not null
;
-- COMMAND ----------
--1
UPDATE tmp.tmp_ims_td_temp_market SET Market_Ratio = 1 WHERE Market_Ratio IS NULL;
-- COMMAND ----------
-- 20260119 依赖 tmp.tmp_ims_td_temp_market
-- 20260119 依赖上面补0 dwd.dwd_gnd_ims_tblkeycompetitor
--KeyCompetitor部分
--Key Competitor
insert overwrite table tmp.tmp_ims_td_temp_market_upd1
select distinct t2.keycompetitor as Key_Competitor,t2.no,t2.no1,t1.*
from tmp.tmp_ims_td_temp_market t1
left join (
select
ROW_NUMBER() OVER(ORDER BY
CASE
WHEN ATC1_Code IS NOT NULL THEN 1
WHEN ATC2_Code IS NOT NULL THEN 2
WHEN ATC3_Code IS NOT NULL THEN 3
WHEN ATC4_Code IS NOT NULL THEN 4
WHEN Molecule_Code IS NOT NULL THEN 5
WHEN Product_Code IS NOT NULL THEN 6
WHEN Pack_Code IS NOT NULL THEN 7
ELSE 999 END,
CASE WHEN NFC1_CODE IS NULL THEN 0 ELSE 1 END,
CASE WHEN NFC2_CODE IS NULL THEN 0 ELSE 1 END,
CASE WHEN NFC2_CODE IS NULL THEN 0 ELSE 1 END,
CASE WHEN NFC3_CODE IS NULL THEN 0 ELSE 1 END
) AS no1,* from dwd.dwd_gnd_ims_tblkeycompetitor
)t2
on t1.ATC1_COD = case when t2.ATC1_Code is null then t1.ATC1_COD else t2.ATC1_Code end
and t1.ATC2_COD = case when t2.ATC2_Code is null then t1.ATC2_COD else t2.ATC2_Code end
and t1.ATC3_COD = case when t2.ATC3_Code is null then t1.ATC3_COD else t2.ATC3_Code end
and t1.ATC4_COD = case when t2.ATC4_Code is null then t1.ATC4_COD else t2.ATC4_Code end
and t1.APP1_COD = case when t2.NFC1_Code is null then t1.APP1_COD else t2.NFC1_Code end
and t1.APP2_COD = case when t2.NFC2_Code is null then t1.APP2_COD else t2.NFC2_Code end
and t1.APP3_COD = case when t2.NFC3_Code is null then t1.APP3_COD else t2.NFC3_Code end
and t1.CORP_COD = case when t2.corporation_code is null then t1.CORP_COD else t2.corporation_code end
and t1.MANU_COD = case when t2.Manufacturer_Code is null then t1.MANU_COD else t2.Manufacturer_Code end
and t1.PROD_COD = case when t2.Product_Code is null then t1.PROD_COD else t2.Product_Code end
and t1.PACK_COD = case when t2.Pack_Code is null then t1.PACK_COD else t2.Pack_Code end
and t1.STGH_DES = case when t2.Strength is null then t1.STGH_DES else t2.Strength end
and t1.CMPS_COD = case when t2.Molecule_Code is null then t1.CMPS_COD else t2.Molecule_Code end
and t1.market = case when t2.market is null then t1.market else t2.market end
;
-- COMMAND ----------
--Key CompetitorNo No最大的一行即最新的规则
insert overwrite table tmp.tmp_ims_td_temp_market_upd2
select * from(
select row_number() over(partition by market,pack_cod,prod_cod order by no1 desc,no desc) as id,*
from tmp.tmp_ims_td_temp_market_upd1) where id>1
;
-- COMMAND ----------
MERGE INTO tmp.tmp_ims_td_temp_market_upd1 AS t1
USING tmp.tmp_ims_td_temp_market_upd2 AS t2
on t1.ATC1_COD = t2.ATC1_COD
and t1.ATC2_COD = t2.ATC2_COD
and t1.ATC3_COD = t2.ATC3_COD
and t1.ATC4_COD = t2.ATC4_COD
and t1.APP1_COD = t2.APP1_COD
and t1.APP2_COD = t2.APP2_COD
and t1.APP3_COD = t2.APP3_COD
and t1.CORP_COD = t2.CORP_COD
and t1.MANU_COD = t2.MANU_COD
and t1.PROD_COD = t2.PROD_COD
and t1.PACK_COD = t2.PACK_COD
and t1.STGH_DES = t2.STGH_DES
and t1.CMPS_COD = t2.CMPS_COD
and t1.market = t2.market
and t1.Key_Competitor = t2.Key_Competitor
and t1.no=t2.no
WHEN MATCHED THEN DELETE
;
-- COMMAND ----------
--KeyCompetitor的Others ,No
update tmp.tmp_ims_td_temp_market_upd1 set Key_Competitor = 'Others' where Key_Competitor is NULL;
-- COMMAND ----------
insert overwrite table tmp.tmp_ims_td_temp_market_upd
select
Key_Competitor,market,PACK_COD,PACK_DES,STGH_DES,PACK_LCH,PROD_COD,CMPS_COD,CMPS_DES,
ATC1_COD,ATC2_COD,ATC3_COD,ATC4_COD,APP1_COD,APP2_COD,APP3_COD,BIO_DESC,GENE_ORIG_DESC,
ETH_OTC_DESC,NRDL_DESC,NRDL_Entry_Date,EDL_DESC,TCM_DESC,PAED_DESC,GQCE_DESC,VBP_DESC,
MANU_COD,MANU_DES,MNFL_COD,MNFL_DES,CORP_COD,CORP_DES,BrandType,bu,Market_Ratio
from tmp.tmp_ims_td_temp_market_upd1
;
-- COMMAND ----------
-- 20260119 市场维度信息 我感觉可以拉到前面去
--
insert overwrite table dws.dws_ims_td_market
select distinct market,PACK_COD,PACK_DES,STGH_DES,PACK_LCH,PROD_COD,CMPS_COD,CMPS_DES,
ATC1_COD,ATC2_COD,ATC3_COD,ATC4_COD,APP1_COD,APP2_COD,APP3_COD,BIO_DESC,GENE_ORIG_DESC,
ETH_OTC_DESC,NRDL_DESC,NRDL_Entry_Date,EDL_DESC,TCM_DESC,PAED_DESC,GQCE_DESC,VBP_DESC,
MANU_COD,MANU_DES,MNFL_COD,MNFL_DES,CORP_COD,CORP_DES,BrandType,bu,Market_Ratio,Key_Competitor,
from_utc_timestamp(current_timestamp(),'UTC+8'),
from_utc_timestamp(current_timestamp(),'UTC+8')
from tmp.tmp_ims_td_temp_market_upd
;