-- Databricks notebook source
---------------------------------bbu county、obu county拆分需求代码示例之事实表字段开发---------------------------------
insert overwrite table dws.dws_ext_county_tf_sales 
select 
distinct
cast(cast(t1.YYYYMM as int) as string) as YYYYMM
,concat(left(cast(t1.YYYYMM as int),4 ),'-',right(cast(t1.YYYYMM as int),2),'-01') as DAY_DATE
,t1.pack_cod as PACK_COD
,t1.region_cod as REGION_COD
,geo.AUDIT_COD
,'ALL' as RELATED_FLAG
,'' as ORG_KEY
,'IMS ALL Market' as MARKET
, concat('IMS ALL Market','_',t1.pack_cod ) as MARKET_PACK_KEY
,'' as MARKET_AUDIT_KEY
,'' as SALES_VALUE
,'' as SALES_VALUE_LY
,'' as SALES_VALUE_L2Y
,'' as SALES_UNIT
,'' as SALES_UNIT_LY
,'' as SALES_UNIT_L2Y
,t1.Counting_Unit as CONUTING_UNIT
,t1.Counting_Unit_LY as CONUTING_UNIT_LY
,'' as CONUTING_UNIT_L2Y
,t1.Counting_Unit as PDOT
,'' as PDOT_LY
,'' as PDOT_L2Y
,t1.SalesValue_LC as SALES_VALUE_CAL
,t1.SalesValue_LC_LY as SALES_VALUE_CAL_LY
,t1.Sales_Unit as SALES_UNIT_CAL
,t1.Sales_Unit_LY as SALES_UNIT_CAL_LY
,from_utc_timestamp(current_timestamp,'UTC+8') as etl_insert_dt
,from_utc_timestamp(current_timestamp,'UTC+8') as etl_update_dt
from tmp.tmp_imscounty_Result t1
left join dm.dm_ims_td_county_geo geo
on t1.region_cod = geo.REGION_COD
