-- Databricks notebook source
-- MAGIC %md
-- MAGIC # AIA

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

-- DBTITLE 1,PACK
CREATE OR REPLACE TABLE DM.DM_TD_EXT_AIA_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 STRING,
  ETL_UPDATE_DT STRING
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_pack_property';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_pack_property';

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

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_AIA_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
  )
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_aia_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_aia_sales';


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

-- DBTITLE 1,PACK2MARKET
CREATE OR REPLACE TABLE DM.DM_TD_EXT_AIA_PACK2MARKET (
  MARKET STRING,
  PACK_CODE STRING,
  PACK_DESC STRING,
  STGH_DESC STRING,
  PACK_LCH STRING,
  PROD_CODE STRING,
  CMPS_CODE STRING,
  CMPS_DESC 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 STRING,
  MANU_CODE STRING,
  MANU_DESC STRING,
  MNFL_CODE STRING,
  MNFL_DESC STRING,
  CORP_CODE STRING,
  CORP_DESC STRING,
  BRANDTYPE STRING,
  BU STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_pack2market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_pack2market';

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

-- DBTITLE 1,MARKET_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_AIA_MARKET_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  CMPS_CODE STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_market_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_market_ratio';

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

-- DBTITLE 1,MARKET_BRAND_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_AIA_MARKET_BRAND_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  VALUE_BRAND_RATIO FLOAT,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO FLOAT,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO FLOAT,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO FLOAT,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_market_brand_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_market_brand_ratio';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_AIA_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_aia_market_pack_mapping';

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

-- MAGIC %md
-- MAGIC #CHC

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

-- DBTITLE 1,PACK
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHC_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 STRING,
  ETL_UPDATE_DT STRING
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_pack_property';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_pack_property';


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

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_CHC_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_chc_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_chc_sales';

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

-- DBTITLE 1,PACK2MARKET
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHC_PACK2MARKET (
  MARKET STRING,
  PACK_CODE STRING,
  PACK_DESC STRING,
  STGH_DESC STRING,
  PACK_LCH STRING,
  PROD_CODE STRING,
  CMPS_CODE STRING,
  CMPS_DESC 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 STRING,
  MANU_CODE STRING,
  MANU_DESC STRING,
  MNFL_CODE STRING,
  MNFL_DESC STRING,
  CORP_CODE STRING,
  CORP_DESC STRING,
  BRANDTYPE STRING,
  BU STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_pack2market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_pack2market';

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

-- DBTITLE 1,MARKET_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHC_MARKET_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  CMPS_CODE STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_market_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_market_ratio';

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

-- DBTITLE 1,MARKET_BRAND_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHC_MARKET_BRAND_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  VALUE_BRAND_RATIO FLOAT,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO FLOAT,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO FLOAT,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO FLOAT,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_market_brand_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_market_brand_ratio';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHC_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chc_market_pack_mapping';

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

-- MAGIC %md
-- MAGIC #CHPA

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

-- DBTITLE 1,PACK
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 STRING,
  ETL_UPDATE_DT STRING
)
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 ----------

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_CHPA_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_chpa_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_chpa_sales';

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

-- DBTITLE 1,PACK2MARKET
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHPA_PACK2MARKET (
  MARKET STRING,
  PACK_CODE STRING,
  PACK_DESC STRING,
  STGH_DESC STRING,
  PACK_LCH STRING,
  PROD_CODE STRING,
  CMPS_CODE STRING,
  CMPS_DESC 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 STRING,
  MANU_CODE STRING,
  MANU_DESC STRING,
  MNFL_CODE STRING,
  MNFL_DESC STRING,
  CORP_CODE STRING,
  CORP_DESC STRING,
  BRANDTYPE STRING,
  BU STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_pack2market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_pack2market';

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

-- DBTITLE 1,MARKET_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHPA_MARKET_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  CMPS_CODE STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_market_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_market_ratio';

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

-- DBTITLE 1,MARKET_BRAND_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHPA_MARKET_BRAND_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  VALUE_BRAND_RATIO FLOAT,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO FLOAT,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO FLOAT,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO FLOAT,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_market_brand_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_market_brand_ratio';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_CHPA_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_chpa_market_pack_mapping';

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

-- MAGIC %md
-- MAGIC # COUNTY

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

-- DBTITLE 1,PACK
CREATE OR REPLACE TABLE DM.DM_TD_EXT_COUNTY_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 STRING,
  ETL_UPDATE_DT STRING
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_pack_property';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_pack_property';


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

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_COUNTY_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_county_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_county_sales';

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

-- DBTITLE 1,PACK2MARKET
-- 建表SQL
CREATE OR REPLACE TABLE DM.DM_TD_EXT_COUNTY_PACK2MARKET (
  MARKET STRING,
  PACK_CODE STRING,
  PACK_DESC STRING,
  STGH_DESC STRING,
  PACK_LCH STRING,
  PROD_CODE STRING,
  CMPS_CODE STRING,
  CMPS_DESC 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 STRING,
  MANU_CODE STRING,
  MANU_DESC STRING,
  MNFL_CODE STRING,
  MNFL_DESC STRING,
  CORP_CODE STRING,
  CORP_DESC STRING,
  BRANDTYPE STRING,
  BU STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_pack2market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_pack2market';

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

-- DBTITLE 1,MARKET_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_COUNTY_MARKET_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  CMPS_CODE STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_market_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_market_ratio';

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

-- DBTITLE 1,MARKET_BRAND_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_COUNTY_MARKET_BRAND_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  VALUE_BRAND_RATIO FLOAT,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO FLOAT,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO FLOAT,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO FLOAT,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_market_brand_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_market_brand_ratio';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_COUNTY_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_county_market_pack_mapping';

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

-- MAGIC %md
-- MAGIC # EC

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

-- DBTITLE 1,PACK
CREATE OR REPLACE TABLE DM.DM_TD_EXT_EC_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 STRING,
  ETL_UPDATE_DT STRING
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_pack_property';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_pack_property';

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

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_EC_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_ec_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_ec_sales';

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

-- DBTITLE 1,PACK2MARKET
CREATE OR REPLACE TABLE DM.DM_TD_EXT_EC_PACK2MARKET (
  MARKET STRING,
  PACK_CODE STRING,
  PACK_DESC STRING,
  STGH_DESC STRING,
  PACK_LCH STRING,
  PROD_CODE STRING,
  CMPS_CODE STRING,
  CMPS_DESC 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 STRING,
  MANU_CODE STRING,
  MANU_DESC STRING,
  MNFL_CODE STRING,
  MNFL_DESC STRING,
  CORP_CODE STRING,
  CORP_DESC STRING,
  BRANDTYPE STRING,
  BU STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_pack2market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_pack2market';

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

-- DBTITLE 1,MARKET_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_EC_MARKET_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  CMPS_CODE STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_market_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_market_ratio';

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

-- DBTITLE 1,MARKET_BRAND_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_EC_MARKET_BRAND_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  VALUE_BRAND_RATIO FLOAT,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO FLOAT,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO FLOAT,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO FLOAT,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_market_brand_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_market_brand_ratio';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_EC_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_ec_market_pack_mapping';

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

-- MAGIC %md
-- MAGIC #RETAIL

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

-- DBTITLE 1,PACK
CREATE OR REPLACE TABLE DM.DM_TD_EXT_RETAIL_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 STRING,
  ETL_UPDATE_DT STRING
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_pack_property';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_pack_property';

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

-- DBTITLE 1,PACK_DTP
CREATE OR REPLACE TABLE DM.DM_TD_EXT_RETAIL_DTP_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 STRING,
  ETL_UPDATE_DT STRING
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_dtp_pack_property';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_dtp_pack_property';

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

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_RETAIL_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_retail_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_retail_sales';

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

-- DBTITLE 1,SALES_DTP
CREATE OR REPLACE TABLE DM.DM_TF_EXT_RETAIL_DTP_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_retail_dtp_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_retail_dtp_sales';

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

-- DBTITLE 1,PACK2MARKET
CREATE OR REPLACE TABLE DM.DM_TD_EXT_RETAIL_PACK2MARKET (
  MARKET STRING,
  PACK_CODE STRING,
  PACK_DESC STRING,
  STGH_DESC STRING,
  PACK_LCH STRING,
  PROD_CODE STRING,
  CMPS_CODE STRING,
  CMPS_DESC 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 STRING,
  MANU_CODE STRING,
  MANU_DESC STRING,
  MNFL_CODE STRING,
  MNFL_DESC STRING,
  CORP_CODE STRING,
  CORP_DESC STRING,
  BRANDTYPE STRING,
  BU STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_pack2market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_pack2market';

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

-- DBTITLE 1,MARKET_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_RETAIL_MARKET_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  CMPS_CODE STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_market_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_market_ratio';

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

-- DBTITLE 1,MARKET_BRAND_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_RETAIL_MARKET_BRAND_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  VALUE_BRAND_RATIO FLOAT,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO FLOAT,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO FLOAT,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO FLOAT,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_market_brand_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_market_brand_ratio';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_RETAIL_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_retail_market_pack_mapping';

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

-- MAGIC %md
-- MAGIC # THC

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

-- DBTITLE 1,PACK
CREATE OR REPLACE TABLE DM.DM_TD_EXT_THC_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 STRING,
  ETL_UPDATE_DT STRING
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_pack_property';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_pack_property';

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

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_THC_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_thc_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_thc_sales';

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

-- DBTITLE 1,PACK2MARKET
CREATE OR REPLACE TABLE DM.DM_TD_EXT_THC_PACK2MARKET (
  MARKET STRING,
  PACK_CODE STRING,
  PACK_DESC STRING,
  STGH_DESC STRING,
  PACK_LCH STRING,
  PROD_CODE STRING,
  CMPS_CODE STRING,
  CMPS_DESC 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 STRING,
  MANU_CODE STRING,
  MANU_DESC STRING,
  MNFL_CODE STRING,
  MNFL_DESC STRING,
  CORP_CODE STRING,
  CORP_DESC STRING,
  BRANDTYPE STRING,
  BU STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_pack2market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_pack2market';

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

-- DBTITLE 1,MARKET_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_THC_MARKET_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  CMPS_CODE STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_market_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_market_ratio';

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

-- DBTITLE 1,MARKET_BRAND_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_THC_MARKET_BRAND_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  VALUE_BRAND_RATIO FLOAT,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO FLOAT,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO FLOAT,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO FLOAT,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_market_brand_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_market_brand_ratio';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_THC_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_thc_market_pack_mapping';

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

-- DBTITLE 1,DM_TF_EXT_THC_MARKET_SALES_CHT
CREATE OR REPLACE TABLE DM.DM_TF_EXT_THC_MARKET_SALES_CHT (
  MARKET STRING,
  KEY_COMPETITOR STRING,
  CLASS STRING,
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  DATA_SOURCE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  CMPS_FLAG STRING COMMENT '分子式标签',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  INST_CODE STRING COMMENT '内部机构编码',
  AIA_HP_FLAG STRING,
  DEPT_NAME STRING COMMENT '科室名称',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_TYPE STRING COMMENT '处方来源',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  VA DOUBLE,
  UT DOUBLE,
  CU DOUBLE,
  PT DOUBLE,
  SALES_UNIT_CAL DECIMAL(35,6),
  SALES_UNIT_CAL_LY DECIMAL(35,6),
  SALES_VALUE_CAL DECIMAL(35,6),
  SALES_VALUE_CAL_LY DECIMAL(35,6),
  CONUTING_UNIT DECIMAL(35,6),
  CONUTING_UNIT_LY DECIMAL(35,6),
  PDOT DECIMAL(35,6),
  PDOT_LY DECIMAL(35,6),
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_thc_market_sales_cht';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_thc_market_sales_cht';

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

-- MAGIC %md
-- MAGIC #XIEHE

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

-- DBTITLE 1,PACK
CREATE OR REPLACE TABLE DM.DM_TD_EXT_XIEHE_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 STRING,
  ETL_UPDATE_DT STRING
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_pack_property';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_pack_property';

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

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_XIEHE_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_xiehe_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_xiehe_sales';

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

-- DBTITLE 1,PACK2MARKET
CREATE OR REPLACE TABLE DM.DM_TD_EXT_XIEHE_PACK2MARKET (
  MARKET STRING,
  PACK_CODE STRING,
  PACK_DESC STRING,
  STGH_DESC STRING,
  PACK_LCH STRING,
  PROD_CODE STRING,
  CMPS_CODE STRING,
  CMPS_DESC 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 STRING,
  MANU_CODE STRING,
  MANU_DESC STRING,
  MNFL_CODE STRING,
  MNFL_DESC STRING,
  CORP_CODE STRING,
  CORP_DESC STRING,
  BRANDTYPE STRING,
  BU STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_pack2market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_pack2market';

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

-- DBTITLE 1,MARKET_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_XIEHE_MARKET_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  CMPS_CODE STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  MARKET_RATIO STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_market_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_market_ratio';

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

-- DBTITLE 1,MARKET_BRAND_RATIO
CREATE OR REPLACE TABLE DM.DM_TD_EXT_XIEHE_MARKET_BRAND_RATIO (
  MARKET STRING,
  PACK_CODE STRING,
  VALUE_BRAND_RATIO FLOAT,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO FLOAT,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO FLOAT,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO FLOAT,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_market_brand_ratio';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_market_brand_ratio';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_XIEHE_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_xiehe_market_pack_mapping';

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

-- MAGIC %md
-- MAGIC #UNIONALL

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

-- DBTITLE 1,PACK
CREATE OR REPLACE TABLE DM.DM_TD_EXT_UNIONALL_PACKINFO (
	PACK_CODE STRING COMMENT '包装编码',
	PACK_DESC STRING COMMENT '包装描述',
	PACK_LCH STRING COMMENT '包装上市时间，示例"Y2024M05"',
	PROD_CODE STRING COMMENT '产品编码',
	PROD_DESC STRING COMMENT '产品描述',
	PROD_DESC_C STRING COMMENT '产品中文描述',
	CMPS_CODE STRING COMMENT '成分代码',
	CMPS_DESC STRING COMMENT '成分描述',
	CMPS_DESC_C STRING COMMENT '成分中文描述',
	VBP_BATCH STRING COMMENT '带量采购批次号',
	VBP_IMPLEMENTING_TIME STRING COMMENT '带量采购实施时间',
	STGH_DESC STRING COMMENT '储存方式描述',
	BIO_DESC STRING COMMENT '生物制药描述',
	ETH_OTC_DESC STRING COMMENT '处方/非处方药描述',
	NRDL_DESC STRING COMMENT '国家医保目录状态描述',
	NRDL_ENTRY_DATE STRING COMMENT '国家医保目录纳入日期',
	EDL_DESC STRING COMMENT '基本药物目录状态描述',
	TCM_DESC STRING COMMENT '中医药分类描述',
	PAED_DESC STRING COMMENT '儿童用药标志描述',
	GQCE_DESC STRING COMMENT '绿色/质量/认证/应急标志描述',
	MANU_CODE STRING COMMENT '生产企业编码',
	MANU_DESC STRING COMMENT '生产企业名称描述',
  MANU_DESC_C STRING COMMENT '生产企业名称中文描述',
	MNFL_CODE STRING COMMENT '跨国/本地企业标志编码',
	ATC1_CODE STRING COMMENT '解剖学治疗学化学分类1编码',
	ATC1_DESC STRING COMMENT '解剖学治疗学化学分类1描述',
	ATC1_DESC_C STRING COMMENT '解剖学治疗学化学分类1中文描述',
	ATC2_CODE STRING COMMENT '解剖学治疗学化学分类2编码',
	ATC2_DESC STRING COMMENT '解剖学治疗学化学分类2描述',
	ATC2_DESC_C STRING COMMENT '解剖学治疗学化学分类2中文描述',
	ATC3_CODE STRING COMMENT '解剖学治疗学化学分类3编码',
	ATC3_DESC STRING COMMENT '解剖学治疗学化学分类3描述',
	ATC3_DESC_C STRING COMMENT '解剖学治疗学化学分类3中文描述',
	ATC4_CODE STRING COMMENT '解剖学治疗学化学分类4编码',
	ATC4_DESC STRING COMMENT '解剖学治疗学化学分类4描述',
	ATC4_DESC_C STRING COMMENT '解剖学治疗学化学分类4中文描述',
	APP1_CODE STRING COMMENT '审批/申请分类(3个层级)',
	APP1_DESC STRING COMMENT '',
	APP1_DESC_C STRING COMMENT '',
	APP2_CODE STRING COMMENT '',
	APP2_DESC STRING COMMENT '',
	APP2_DESC_C STRING COMMENT '',
	APP3_CODE STRING COMMENT '',
	APP3_DESC STRING COMMENT '',
	APP3_DESC_C STRING COMMENT '',
	GENE_ORIG_DESC STRING COMMENT '原研/仿制/中药药物来源描述',
	VBP_DESC STRING COMMENT '带量采购状态(VBP-IN/VBP-OUT/Non VBP)描述',
	CORP_CODE STRING COMMENT '公司编码',
	GEN_RN INT COMMENT '原研/仿制排名(1-5)',
	CORP_DESC STRING COMMENT '公司名称描述',
	CORP_DESC_C STRING COMMENT '公司名称中文描述',
	PACK_RN INT COMMENT '包装排名(按销售量)',
	PROD_RN INT COMMENT '产品排名(按销售量)',
	CMPS_RN INT COMMENT '成分排名(按销售量)',
	DATA_SOURCE STRING COMMENT '数据来源渠道',
	ATC STRING COMMENT 'ATC分类代码',
	NEW_CODE STRING COMMENT '新编码',
	COMMON_NAME STRING COMMENT '通用名称',
	PRODUCT_NAME STRING COMMENT '产品名称',
	MANU_DES_XIEHE STRING COMMENT '协和渠道生产企业名称',
	PACK_DES_XIEHE STRING COMMENT '协和渠道包装描述',
	DRUG_DELIVERY_ROUTE STRING COMMENT '给药途径',
	NFC STRING COMMENT '国家处方集代码',
	CORP_TYPE STRING COMMENT '企业类型(本地/跨国)',
	LAUNCHTIME STRING COMMENT '产品上市时间',
	VBP_BRAND STRING COMMENT '品牌带量采购状态汇总',
  REPLENISH_FALG STRING COMMENT '后续补充标志',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_unionall_packinfo';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_unionall_packinfo';

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

-- DBTITLE 1,SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_UNIONALL_SALES (
  YYYYMM STRING,
  PACK_CODE STRING,
  CORP_CODE STRING,
  AUDIT_CODE STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(38,10),
  CONUTING_UNIT_LY DECIMAL(38,10),
  DATA_SOURCE STRING,
  INST_CODE STRING COMMENT '内部机构编码',
  CMPS_FLAG STRING COMMENT '分子式标签',
  DEPT_NAME STRING COMMENT '科室名称',
  PRESCRIPTION DECIMAL(38,10) COMMENT '处方张数',
  PRESCRIPTION_LY DECIMAL(38,10) COMMENT '去年同期处方张数',
  NEW_CODE STRING COMMENT '主数据关联CODE',
  AREA STRING COMMENT '城市',
  H_LEVEL STRING COMMENT '医院类型',
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_SOURCE STRING COMMENT '处方来源',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_unionall_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_unionall_sales';

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

-- DBTITLE 1,MARKET_PACK_MAPPING
CREATE OR REPLACE TABLE DM.DM_TD_EXT_UNIONALL_MARKET_PACK_MAPPING
(
  PACK_CODE STRING,
  MARKET STRING,
  CLASS STRING,
  KEY_COMPETITOR STRING,
  MARKET_RATIO STRING,
  STARTTIME STRING,
  ENDTIME STRING,
  VALUE_BRAND_RATIO STRING,
  VALUE_BRAND_RATIO_START STRING,
  VALUE_BRAND_RATIO_END STRING,
  UNIT_BRAND_RATIO STRING,
  UNIT_BRAND_START STRING,
  UNIT_BRAND_END STRING,
  COUNTINGUNIT_BRAND_RATIO STRING,
  COUNTINGUNIT_BRAND_START STRING,
  COUNTINGUNIT_BRAND_END STRING,
  PDOT_BRAND_RATIO STRING,
  PDOT_BRAND_START STRING,
  PDOT_BRAND_END STRING,
  DATASOURCE STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_unionall_market_pack_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_unionall_market_pack_mapping';

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

-- DBTITLE 1,MARKET_SALES
CREATE OR REPLACE TABLE DM.DM_TF_EXT_UNIONALL_MARKET_SALES (
  MARKET STRING,
  KEY_COMPETITOR STRING,
  CLASS STRING,
  YYYYMM STRING,
  PACK_COD STRING,
  CORP_COD STRING,
  AUDIT_COD STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  DATA_SOURCE STRING,
  PACK_FLAG STRING,
  PROD_FLAG STRING,
  DTP_FLAG STRING,
  CMPS_FLAG STRING,
  NEW_CODE STRING COMMENT '主数据关联CODE',
  INST_CODE STRING COMMENT '内部机构编码',
  AIA_HP_FLAG STRING,
  DEPT_NAME STRING COMMENT '科室名称',
  H_LEVEL STRING,
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_TYPE STRING COMMENT '处方来源',
  PRESCRIPTION DECIMAL(35,10),
  PRESCRIPTION_LY DECIMAL(35,10),
  VA STRING,
  UT STRING,
  CU STRING,
  PT STRING,
  SALES_UNIT_CAL DECIMAL(35,6),
  SALES_UNIT_CAL_LY DECIMAL(35,6),
  SALES_VALUE_CAL DECIMAL(35,6),
  SALES_VALUE_CAL_LY DECIMAL(35,6),
  CONUTING_UNIT DECIMAL(35,6),
  CONUTING_UNIT_LY DECIMAL(35,6),
  PDOT DECIMAL(35,6),
  PDOT_LY DECIMAL(35,6),
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP
  )
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_unionall_market_sales';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_unionall_market_sales';

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

-- DBTITLE 1,SALES_MAPPING
CREATE OR REPLACE TABLE DM.DM_TF_EXT_UNIONALL_SALES_MAPPING 
(
  MARKET STRING,
  KEY_COMPETITOR STRING,
  CLASS STRING,
  YYYYMM STRING,
  PACK_COD STRING,
  CORP_COD STRING,
  AUDIT_COD STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  DATA_SOURCE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  CMPS_FLAG INT,
  NEW_CODE STRING COMMENT '主数据关联CODE',
  INST_CODE STRING COMMENT '内部机构编码',
  AIA_HP_FLAG INT,
  DEPT_NAME STRING COMMENT '科室名称',
  H_LEVEL INT,
  REIMBURSE STRING COMMENT '报销情况',
  REIMBURSE_TYPE STRING COMMENT '报销类型',
  PRESCRIPTION_TYPE STRING COMMENT '处方来源',
  VA decimal(35,10),
  UT decimal(35,10),
  CU decimal(35,10),
  PT decimal(35,10),
  SALES_UNIT_CAL decimal(35,10),
  SALES_UNIT_CAL_LY decimal(35,10),
  SALES_VALUE_CAL decimal(35,10),
  SALES_VALUE_CAL_LY decimal(35,10),
  CONUTING_UNIT decimal(35,10),
  CONUTING_UNIT_LY decimal(35,10),
  PDOT decimal(35,10),
  PDOT_LY decimal(35,10),
  PRESCRIPTION INT,
  PRESCRIPTION_LY INT,
  AIA_REMOVE INT,
  MERGEDATA_FLAG STRING,
  MERGEDATA_FLAG_MKT STRING,
  MERGEDATA_FLAG_CHPA_DTP INT,
  MERGEDATA_FLAG_DTP_NOROC INT,
  MERGED_DATA_DTP_OTHERS INT,
  EGFR_FLAG INT,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_unionall_sales_mapping';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_tf_ext_unionall_sales_mapping';

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

-- MAGIC %md
-- MAGIC # OTHER

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

-- DBTITLE 1,dm_td_ext_unionall_market
CREATE OR REPLACE TABLE DM.DM_TD_EXT_UNIONALL_MARKET (
  MARKET STRING,
  DATA_SOURCE STRING,
  TA STRING,
  AZ_RELATED STRING,
  MARKET_DESC STRING,
  TA_RN INT,
  PRD_FLAG STRING,
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_unionall_market';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_unionall_market';

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

-- DBTITLE 1,dm_td_ext_unionall_market_ta
CREATE OR REPLACE TABLE DM.DM_TD_EXT_UNIONALL_MARKET_TA (
  MARKET STRING COMMENT '市场',
  DATA_SOURCE STRING COMMENT '数据源',
  TA STRING COMMENT '治疗领域',
  TA_MAP STRING COMMENT '治疗领域匹配',
  TA_RN INT COMMENT '治疗领域排名',
  MARKET_DESC STRING COMMENT '市场描述',
  ETL_INSERT_DT TIMESTAMP,
  ETL_UPDATE_DT TIMESTAMP)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/dm_td_ext_unionall_market_ta';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/dm_td_ext_unionall_market_ta';

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

-- DBTITLE 1,DM_TF_EXTERANL_SALES_MERGED_DATA_DTP_OTHERS_bymonth
CREATE OR REPLACE TABLE dm.DM_TF_EXTERANL_SALES_MERGED_DATA_DTP_OTHERS_bymonth (
  MARKET STRING,
  KEY_COMPETITOR STRING,
  CLASS STRING,
  YYYYMM STRING,
  PACK_COD STRING,
  CORP_COD STRING,
  AUDIT_COD STRING,
  PLATFORM_TYPE STRING,
  STORE_NAME STRING,
  STORE_TYPE STRING,
  REGION_TYPE STRING,
  PACK_FLAG INT,
  PROD_FLAG INT,
  DTP_FLAG INT,
  SALES_UNIT_CAL DECIMAL(38,10),
  SALES_UNIT_CAL_LY DECIMAL(38,10),
  SALES_VALUE_CAL DECIMAL(38,10),
  SALES_VALUE_CAL_LY DECIMAL(38,10),
  CONUTING_UNIT DECIMAL(21,0),
  CONUTING_UNIT_LY DECIMAL(21,0),
  PDOT DECIMAL(21,0),
  PDOT_LY DECIMAL(21,0),
  DATA_SOURCE STRING,
  inst_code STRING,
  cmps_flag STRING,
  dept_name STRING,
  prescription STRING,
  prescription_ly STRING,
  new_code STRING,
  area STRING,
  h_level STRING,
  reimburse STRING,
  reimburse_type STRING,
  prescription_source STRING)
USING delta
LOCATION 'abfss://master@azcdatalakeprd.dfs.core.chinacloudapi.cn/DM/DM_TF_EXTERANL_SALES_MERGED_DATA_DTP_OTHERS_bymonth';
-- 上面是生产环境location，下面是测试环境location
-- LOCATION 'abfss://master@retaildlstoragetest.dfs.core.chinacloudapi.cn/DM/DM_TF_EXTERANL_SALES_MERGED_DATA_DTP_OTHERS_bymonth';
