Skip to content

Commit

Permalink
Adding config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vishreddy01 committed Feb 8, 2024
1 parent 0c41abc commit 1a8e7dc
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 1 deletion.
15 changes: 15 additions & 0 deletions pmt/dbt/pmt_dbt/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ghcr.io/dbt-labs/dbt-postgres

RUN chmod -R g+rwX /usr

COPY . /usr/app/dbt/

COPY profiles.yml /usr/app/dbt/.dbt/profiles.yml

COPY dbt_project.yml /app/dbt_project.yml

WORKDIR /usr/app/dbt/

# dbt is already initiated

CMD ["--help"]
13 changes: 12 additions & 1 deletion pmt/dbt/pmt_dbt/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_packages"


vars:
# The `start_date` variable will be accessible in all resources
db_fdw_rrs: fdw_ods_rrs_replication


# Configuring models
# Full documentation: https://docs.getdbt.com/docs/configuring-models

Expand All @@ -35,3 +39,10 @@ models:
# Config indicated by + and applies to all files under models/example/
example:
+materialized: view
dpl:
+schema: pmt_dpl
dal:
+schema: pmt_dal
sandbox:
+schema: pmt_sandbox

14 changes: 14 additions & 0 deletions pmt/dbt/pmt_dbt/macros/generate_schema_name.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% macro generate_schema_name(custom_schema_name, node) -%}

{%- set default_schema = target.schema -%}
{%- if custom_schema_name is none -%}

{{ default_schema }}

{%- else -%}

{{ custom_schema_name | trim }}

{%- endif -%}

{%- endmacro %}
34 changes: 34 additions & 0 deletions pmt/dbt/pmt_dbt/profiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pmt_dbt:
outputs:

dev:
type: postgres
threads: 2
host: theory.bcgov
port: 5443
user: dlh_admin_user
pass: "{{ env_var('dlh_password') }}"
dbname: lhousedev
schema: public

test:
type: postgres
threads: 2
host: theory.bcgov
port: 5444
user: dlh_admin_user
pass: "{{ env_var('dlh_password') }}"
dbname: lhousetst
schema: public

prod:
type: postgres
threads: 2
host: existence.bcgov
port: 5436
user: dlh_admin_user
pass: "{{ env_var('dlh_password') }}"
dbname: lhouseprd
schema: public

target: dev
34 changes: 34 additions & 0 deletions pmt/dbt/pmt_dbt/snapshots/dpl/dim_org.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% snapshot dim_org %}

{{
config(
target_schema='pmt_dpl',
strategy='check',
unique_key='pi_hash_key',
check_cols='all',
bind=False,
)
}}

WITH scd_data AS (
SELECT
'CORP' as src_sys_code
,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
,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,
-- Combine multiple keys into a single composite_key
md5(coalesce(cast('COPR' as varchar),'~') || '|'||
coalesce(cast(org_unit_code as varchar),'~')) as pi_hash_key
FROM fdw_ods_fta_replication.org_unit org
)

SELECT *
FROM scd_data


{% endsnapshot %}

0 comments on commit 1a8e7dc

Please sign in to comment.