-- Databricks notebook source
--NFC挂中文名
insert overwrite table dws.dws_ims_td_nfc_cn
SELECT  DISTINCT T1.NFC1_CODE AS APP1_COD ,
		T1.NFC1_DES AS APP1_DES,
		case when NFC1.APP1_DES_C is null then T1.NFC1_DES else NFC1.APP1_DES_C end AS APP1_DES_C,
		T1.NFC2_CODE AS APP2_COD ,
		T1.NFC2_DES AS APP2_DES,
		case when NFC2.APP2_DES_C is null then T1.NFC2_DES else NFC2.APP2_DES_C end AS APP2_DES_C,
		T1.NFC3_CODE AS APP3_COD, 
		T1.NFC3_DES AS APP3_DES,
		case when NFC3.APP3_DES_C is null then T1.NFC3_DES else NFC3.APP3_DES_C end AS APP3_DES_C,
      from_utc_timestamp(current_timestamp(),'UTC+8'),
      from_utc_timestamp(current_timestamp(),'UTC+8')
FROM dwd.dwd_ims_NFC_Hierarchy T1
LEFT JOIN (SELECT DISTINCT APP3_COD,APP3_DES_C FROM dwd.dwd_gnd_ims_tblAPP) NFC3
ON T1.NFC3_CODE = NFC3.APP3_COD
LEFT JOIN (SELECT DISTINCT APP2_COD,APP2_DES_C FROM dwd.dwd_gnd_ims_tblAPP)  NFC2
ON T1.NFC2_CODE = NFC2.APP2_COD
LEFT JOIN (SELECT DISTINCT APP1_COD,APP1_DES_C FROM dwd.dwd_gnd_ims_tblAPP)  NFC1
ON T1.NFC1_CODE = NFC1.APP1_COD
;