-- Databricks notebook source
--county事实表加上region_type字段
insert overwrite table dm.dm_ext_county_tf_sales_region 
select
  A.YYYYMM,
  A.DAY_DATE,
  A.PACK_COD,
  A.REGION_COD,
  A.AUDIT_COD,
  A.RELATED_FLAG,
  A.ORG_KEY,
  A.MARKET,
  A.MARKET_PACK_KEY,
  A.MARKET_AUDIT_KEY,
  A.SALES_VALUE,
  A.SALES_VALUE_LY,
  A.SALES_VALUE_L2Y,
  A.SALES_UNIT,
  A.SALES_UNIT_LY,
  A.SALES_UNIT_L2Y,
  A.CONUTING_UNIT,
  A.CONUTING_UNIT_LY,
  A.CONUTING_UNIT_L2Y,
  A.PDOT,
  A.PDOT_LY,
  A.PDOT_L2Y,
  A.SALES_VALUE_CAL,
  A.SALES_VALUE_CAL_LY,
  A.SALES_UNIT_CAL,
  A.SALES_UNIT_CAL_LY,
  A.etl_insert_dt,
  A.etl_update_dt,
  B.region_type as REGION_TYPE
from dws.dws_ext_county_tf_sales A
left join dm.dm_td_county_pack_region B
on A.PACK_COD = B.pack_cod and A.REGION_COD = B.region_cod
order by region_type
