Skip to content

Commit

Permalink
Updating code to handle regions
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikas Grover authored and Vikas Grover committed Feb 14, 2024
1 parent e2fe429 commit 118d0d7
Show file tree
Hide file tree
Showing 3 changed files with 475 additions and 31 deletions.
21 changes: 13 additions & 8 deletions pmt/dbt/pmt_dbt/snapshots/dpl/dim_org.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@ with corp_data as (
,org.org_unit_code as org_unit_code
,org.org_unit_name as org_unit_description
,org.rollup_region_code as rollup_region_code
,null as rollup_region_description
,reg.org_unit_name as rollup_region_description
,org.rollup_dist_code as rollup_district_code
,null as rollup_district_description
,null as roll_up_area_code
,null as roll_up_area_description
,rdis.org_unit_name as rollup_district_description
,case when org.rollup_dist_code in ('DCC','DQU','DMH','DRM','DSE','DOS','DCS','DKA') then 'SA'
when org.rollup_dist_code in ('DFN','DPC','DPG','DMK','DVA','DKM','DSS','DND') then 'NA'
when org.rollup_dist_code in ('DSC','DSQ','DCK','DNI','DSI','DQC','DCR') then 'CA' end as roll_up_area_code
,case when org.rollup_dist_code in ('DCC','DQU','DMH','DRM','DSE','DOS','DCS','DKA') then 'South Area'
when org.rollup_dist_code in ('DFN','DPC','DPG','DMK','DVA','DKM','DSS','DND') then 'North Area'
when org.rollup_dist_code in ('DSC','DSQ','DCK','DNI','DSI','DQC','DCR') then 'Coast Area' end as roll_up_area_description
-- Combine multiple keys into a single composite_key
,'CORP' || '|'|| coalesce(cast(org_unit_code as varchar),'~') as unqid
,'CORP' || '|'|| coalesce(cast(org.org_unit_code as varchar),'~') as unqid
from fdw_ods_fta_replication.org_unit org
)
left join fdw_ods_fta_replication.org_unit reg on (org.rollup_region_code = reg.org_unit_code)
left join fdw_ods_fta_replication.org_unit rdis on (org.rollup_dist_code = rdis.org_unit_code)
)
--insert into pmt_dpl.dim_org
select *
from corp_data
select * from corp_data
;

{% endsnapshot %}
8 changes: 4 additions & 4 deletions pmt/dbt/pmt_dbt/snapshots/dpl/dim_project.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with ats_data as (
prj.project_name,
prj.location,
prj.project_status_code,
amfr.region_name,
amfr.region_name as project_region_description,
'ATS' || '|'|| coalesce(cast(prj.project_id as varchar),'~') as unqid
from fdw_ods_ats_replication.ats_projects prj
left join fdw_ods_ats_replication.ats_managing_fcbc_regions amfr ---dim_regions
Expand All @@ -32,7 +32,7 @@ fta_data as (
,null as project_name
,null as location
,null as project_status_code
,null as region_name
,null as project_region_description
,'FTA' || '|'|| coalesce(cast(null as varchar(5)),'~') as unqid

)
Expand All @@ -43,7 +43,7 @@ rrs_rp_data as (
,null as project_name
,null as location
,null as project_status_code
,null as region_name
,null as project_region_description
,'RRS_RP' || '|'|| coalesce(cast(null as varchar(5)),'~') as unqid
)
,
Expand All @@ -53,7 +53,7 @@ rrs_rup_data as (
,null as project_name
,null as location
,null as project_status_code
,null as region_name
,null as project_region_description
,'RRS_RUP' || '|'|| coalesce(cast(null as varchar(5)),'~') as unqid
)
--insert into pmt_dpl.dim_project
Expand Down
Loading

0 comments on commit 118d0d7

Please sign in to comment.