Skip to content

Commit 6936096

Browse files
Feature/Staff Contact Associations Base/Stage (#127)
* added base and stage models for staff ed org contact associations * fixed email address name * updated reference in base model, and in stage updated the partition by of the dedupe, the order by, and moved where not is_deleted to the bottom selection * lower email address for future use * Update CHANGELOG.md --------- Co-authored-by: rlittle08 <rlittle@edanalytics.org>
1 parent cb1e715 commit 6936096

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Unreleased
22
## New features
3-
- Add (optional) support for incremental materialization of most expensive stg models
3+
- Add base/stage models for `staffEducationOrganizationContactAssociations`
4+
- Add (optional) support for incremental materialization of most expensive stg models
45
## Under the hood
56
## Fixes
67

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
with staff_ed_org_contact_assoc as (
2+
{{ source_edfi3('staff_education_organization_contact_associations') }}
3+
),
4+
renamed as (
5+
select
6+
tenant_code,
7+
api_year,
8+
pull_timestamp,
9+
last_modified_timestamp,
10+
file_row_number,
11+
filename,
12+
is_deleted,
13+
v:id::string as record_guid,
14+
v:contactTitle::string as contact_title,
15+
v:educationOrganizationReference:educationOrganizationId::int as ed_org_id,
16+
lower(v:electronicMailAddress::string) as email_address,
17+
v:staffReference:staffUniqueId::int as staff_unique_id,
18+
-- arrays
19+
v:telephones as v_telephones,
20+
-- references
21+
v:educationOrganizationReference as education_organization_reference,
22+
v:staffReference as staff_reference,
23+
-- edfi extensions
24+
v:_ext as v_ext
25+
26+
from staff_ed_org_contact_assoc
27+
)
28+
select * from renamed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
with base_staff_ed_org_contact_assoc as (
2+
select * from {{ ref('base_ef3__staff_education_organization_contact_associations') }}
3+
),
4+
keyed as (
5+
select
6+
{{ gen_skey('k_staff') }},
7+
{{ edorg_ref() }},
8+
api_year as school_year,
9+
base_staff_ed_org_contact_assoc.*
10+
{{ extract_extension(model_name=this.name, flatten=True) }}
11+
from base_staff_ed_org_contact_assoc
12+
),
13+
deduped as (
14+
{{
15+
dbt_utils.deduplicate(
16+
relation='keyed',
17+
partition_by= 'k_staff, ed_org_id, contact_title, api_year',
18+
order_by='last_modified_timestamp desc, pull_timestamp desc'
19+
)
20+
}}
21+
)
22+
select * from deduped
23+
where not is_deleted

0 commit comments

Comments
 (0)