-- Databricks notebook source
-- CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHPA_PACK_PROPERTY 
-- (
--   -- MARKET_PACK_KEY STRING,
--   PACK_CODE STRING,
--   PACK_DESC STRING,
--   STGH_DESC STRING,
--   PACK_LCH STRING,
--   FAMILY_CODE STRING,
--   FAMILY_NAME STRING,
--   PROD_CODE STRING,
--   PROD_DESC STRING,
--   PROD_DESC_C STRING,
--   CMPS_CODE STRING,
--   CMPS_DESC STRING,
--   CMPS_DESC_C STRING,
--   ATC1_CODE STRING,
--   ATC2_CODE STRING,
--   ATC3_CODE STRING,
--   ATC4_CODE STRING,
--   APP1_CODE STRING,
--   APP2_CODE STRING,
--   APP3_CODE STRING,
--   BIO_DESC STRING,
--   GENE_ORIG_DESC STRING,
--   ETH_OTC_DESC STRING,
--   NRDL_DESC STRING,
--   NRDL_ENTRY_DATE STRING,
--   EDL_DESC STRING,
--   TCM_DESC STRING,
--   PAED_DESC STRING,
--   GQCE_DESC STRING,
--   VBP_DESC_V STRING,
--   VBP_DESC STRING,
--   MANU_CODE STRING,
--   MANU_DESC STRING,
--   MANU_DESC_C STRING,
--   MNFL_CODE STRING,
--   MNFL_DESC STRING,
--   CORP_CODE STRING,
--   CORP_DESC STRING,
--   CORP_DESC_C STRING,
--   BRANDTYPE STRING,
--   -- MARKET STRING,
--   -- KEY_COMPETITOR STRING,
--   IS_AZ STRING,
--   AZ_MAIN STRING,
--   -- AZ_RELATED STRING,
--   ATC1_DESC STRING,
--   ATC1_DESC_C STRING,
--   ATC2_DESC STRING,
--   ATC2_DESC_C STRING,
--   ATC3_DESC STRING,
--   ATC3_DESC_C STRING,
--   ATC4_DESC STRING,
--   ATC4_DESC_C STRING,
--   APP1_DESC STRING,
--   APP1_DESC_C STRING,
--   APP2_DESC STRING,
--   APP2_DESC_C STRING,
--   APP3_DESC STRING,
--   APP3_DESC_C STRING,
--   -- CLASS STRING,
--   -- MARKET_RATIO STRING,
--   COUNTINGUNIT STRING,
--   VBP_BRAND STRING,
--   REPLENISH_FALG STRING,
--   ETL_INSERT_DT TIMESTAMP,
--   ETL_UPDATE_DT TIMESTAMP
-- )
-- USING delta
-- -- LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_pack_property';
-- -- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_pack_property';

-- COMMAND ----------

INSERT OVERWRITE TABLE DM.DM_TD_EXT_CHPA_PACK_PROPERTY
SELECT
  -- MARKET_PACK_KEY,
  PACK_COD AS PACK_CODE,
  PACK_DES AS PACK_DESC,
  STGH_DES AS STGH_DESC,
  PACK_LCH,
  FAMILY_CODE,
  FAMILY_NAME,
  PROD_COD AS PROD_CODE,
  PROD_DES AS PROD_DESC,
  PROD_DES_C AS PROD_DESC_C,
  CMPS_COD AS CMPS_CODE,
  CMPS_DES AS CMPS_DESC,
  CMPS_DES_C AS CMPS_DESC_C,
  ATC1_COD AS ATC1_CODE,
  ATC2_COD AS ATC2_CODE,
  ATC3_COD AS ATC3_CODE,
  ATC4_COD AS ATC4_CODE,
  APP1_COD AS APP1_CODE,
  APP2_COD AS APP2_CODE,
  APP3_COD AS APP3_CODE,
  BIO_DESC,
  GENE_ORIG_DESC,
  ETH_OTC_DESC,
  NRDL_DESC,
  NRDL_ENTRY_DATE,
  EDL_DESC,
  TCM_DESC,
  PAED_DESC,
  GQCE_DESC,
  VBP_DESC_V,
  VBP_DESC,
  MANU_COD AS MANU_CODE,
  MANU_DES AS MANU_DESC,
  MANU_DES_C AS MANU_DESC_C,
  MNFL_COD AS MNFL_CODE,
  MNFL_DES AS MNFL_DESC,
  CORP_COD AS CORP_CODE,
  CORP_DES AS CORP_DESC,
  CORP_DES_C AS CORP_DESC_C,
  BRANDTYPE,
  -- MARKET,
  -- KEY_COMPETITOR,
  IS_AZ,
  AZ_MAIN,
  -- AZ_RELATED,
  ATC1_DES AS ATC1_DESC,
  ATC1_DES_C AS ATC1_DESC_C,
  ATC2_DES AS ATC2_DESC,
  ATC2_DES_C AS ATC2_DESC_C,
  ATC3_DES AS ATC3_DESC,
  ATC3_DES_C AS ATC3_DESC_C,
  ATC4_DES AS ATC4_DESC,
  ATC4_DES_C AS ATC4_DESC_C,
  APP1_DES AS APP1_DESC,
  APP1_DES_C AS APP1_DESC_C,
  APP2_DES AS APP2_DESC,
  APP2_DES_C AS APP2_DESC_C,
  APP3_DES AS APP3_DESC,
  APP3_DES_C AS APP3_DESC_C,
  -- CLASS,
  -- NULL AS MARKET_RATIO,
  NULL AS COUNTINGUNIT,
  NULL AS VBP_BRAND,
  NULL AS REPLENISH_FALG,
  FROM_UTC_TIMESTAMP(CURRENT_TIMESTAMP(),'UTC+8') AS ETL_INSERT_DT,
  FROM_UTC_TIMESTAMP(CURRENT_TIMESTAMP(),'UTC+8') AS ETL_UPDATE_DT
FROM DM.DM_IMS_TD_PACK_PROPERTY
;