-- Databricks notebook source
-- 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 ----------

INSERT OVERWRITE TABLE DM.DM_TD_EXT_COUNTY_MARKET_RATIO
SELECT 
  DISTINCT
  MARKET,
  PACK_CODE,
  CMPS_CODE,
  STARTTIME,
  ENDTIME,
  MARKET_RATIO,
  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_TD_EXT_COUNTY_PACK2MARKET
WHERE UPPER(MARKET) NOT LIKE '%ALL%MARKET'
