Skip to content

Commit 6817dc9

Browse files
authored
Feature/staff stg updates (#62)
* fix credential state location * add staff employment base/stg * add staff races * remove outdated todo
1 parent d533454 commit 6817dc9

6 files changed

+79
-3
lines changed

models/staging/edfi_3/base/_edfi_3__base.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ models:
9494
- name: base_ef3__staff_education_organization_assignment_associations
9595
config:
9696
tags: ['core']
97+
- name: base_ef3__staff_education_organization_employment_associations
98+
config:
99+
tags: ['core']
97100
- name: base_ef3__staff_school_associations
98101
config:
99102
tags: ['core']

models/staging/edfi_3/base/base_ef3__staff_education_organization_assignment_associations.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ renamed as (
2020
v:orderOfAssignment::float as order_of_assignment,
2121
v:credentialReference:credentialIdentifier::string as credential_identifier,
2222
-- descriptors
23-
{{ extract_descriptor('v:stateOfIssueStateAbbreviationDescriptor::string') }} as credential_state,
24-
{{ extract_descriptor('v:staffClassificationDescriptor::string') }} as staff_classification,
23+
{{ extract_descriptor('v:credentialReference:stateOfIssueStateAbbreviationDescriptor::string') }} as credential_state,
24+
{{ extract_descriptor('v:staffClassificationDescriptor::string') }} as staff_classification,
2525
-- references
2626
v:credentialReference as credential_reference,
2727
v:educationOrganizationReference as education_organization_reference,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
with staff_ed_org_employ as (
2+
{{ source_edfi3('staff_education_organization_employment_associations') }}
3+
),
4+
renamed as (
5+
select
6+
tenant_code,
7+
api_year,
8+
pull_timestamp,
9+
file_row_number,
10+
filename,
11+
is_deleted,
12+
v:id::string as record_guid,
13+
v:educationOrganizationReference:educationOrganizationId::int as ed_org_id,
14+
v:educationOrganizationReference:link:rel::string as ed_org_type,
15+
v:staffReference:staffUniqueId::string as staff_unique_id,
16+
v:credentialReference:credentialIdentifier::string as credential_identifier,
17+
v:department::string as department,
18+
v:hireDate::date as hire_date,
19+
v:endDate::date as end_date,
20+
v:fullTimeEquivalency::float as full_time_equivalency,
21+
v:hourlyWage::float as hourly_wage,
22+
v:annualWage::float as annual_wage,
23+
v:offerDate::date as offer_date,
24+
-- descriptors
25+
{{ extract_descriptor('v:employmentStatusDescriptor::string') }} as employment_status,
26+
{{ extract_descriptor('v:credentialReference:stateOfIssueStateAbbreviationDescriptor::string') }} as credential_state,
27+
{{ extract_descriptor('v:separationDescriptor::string') }} as separation,
28+
{{ extract_descriptor('v:separationReasonDescriptor::string') }} as separation_reason,
29+
-- references
30+
v:credentialReference as credential_reference,
31+
v:educationOrganizationReference as education_organization_reference,
32+
v:staffReference as staff_reference,
33+
-- edfi extensions
34+
v:_ext as v_ext
35+
from staff_ed_org_employ
36+
)
37+
select * from renamed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
with stage_staffs as (
2+
select * from {{ ref('stg_ef3__staffs') }}
3+
),
4+
flattened as (
5+
select
6+
tenant_code,
7+
api_year,
8+
k_staff,
9+
{{ extract_descriptor('value:raceDescriptor::string') }} as race
10+
from stage_staffs
11+
, lateral flatten(input=>v_races)
12+
)
13+
select * from flattened
14+

models/staging/edfi_3/stage/stg_ef3__staff_education_organization_assignment_associations.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ with base_staff_ed_org_assign as (
55
keyed as (
66
select
77
{{ gen_skey('k_staff') }},
8-
--todo: edorg
98
{{ edorg_ref() }},
109
api_year as school_year,
1110
base_staff_ed_org_assign.*
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
with base_staff_ed_org_employ as (
2+
select * from {{ ref('base_ef3__staff_education_organization_employment_associations') }}
3+
where not is_deleted
4+
),
5+
keyed as (
6+
select
7+
{{ gen_skey('k_staff') }},
8+
{{ edorg_ref() }},
9+
api_year as school_year,
10+
base_staff_ed_org_employ.*
11+
{{ extract_extension(model_name=this.name, flatten=True) }}
12+
from base_staff_ed_org_employ
13+
),
14+
deduped as (
15+
{{
16+
dbt_utils.deduplicate(
17+
relation='keyed',
18+
partition_by= 'tenant_code, api_year, ed_org_id, employment_status, hire_date, staff_unique_id',
19+
order_by='api_year desc, pull_timestamp desc'
20+
)
21+
}}
22+
)
23+
select * from deduped

0 commit comments

Comments
 (0)