-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix credential state location * add staff employment base/stg * add staff races * remove outdated todo
- Loading branch information
Showing
6 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ls/staging/edfi_3/base/base_ef3__staff_education_organization_employment_associations.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
with staff_ed_org_employ as ( | ||
{{ source_edfi3('staff_education_organization_employment_associations') }} | ||
), | ||
renamed as ( | ||
select | ||
tenant_code, | ||
api_year, | ||
pull_timestamp, | ||
file_row_number, | ||
filename, | ||
is_deleted, | ||
v:id::string as record_guid, | ||
v:educationOrganizationReference:educationOrganizationId::int as ed_org_id, | ||
v:educationOrganizationReference:link:rel::string as ed_org_type, | ||
v:staffReference:staffUniqueId::string as staff_unique_id, | ||
v:credentialReference:credentialIdentifier::string as credential_identifier, | ||
v:department::string as department, | ||
v:hireDate::date as hire_date, | ||
v:endDate::date as end_date, | ||
v:fullTimeEquivalency::float as full_time_equivalency, | ||
v:hourlyWage::float as hourly_wage, | ||
v:annualWage::float as annual_wage, | ||
v:offerDate::date as offer_date, | ||
-- descriptors | ||
{{ extract_descriptor('v:employmentStatusDescriptor::string') }} as employment_status, | ||
{{ extract_descriptor('v:credentialReference:stateOfIssueStateAbbreviationDescriptor::string') }} as credential_state, | ||
{{ extract_descriptor('v:separationDescriptor::string') }} as separation, | ||
{{ extract_descriptor('v:separationReasonDescriptor::string') }} as separation_reason, | ||
-- references | ||
v:credentialReference as credential_reference, | ||
v:educationOrganizationReference as education_organization_reference, | ||
v:staffReference as staff_reference, | ||
-- edfi extensions | ||
v:_ext as v_ext | ||
from staff_ed_org_employ | ||
) | ||
select * from renamed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
with stage_staffs as ( | ||
select * from {{ ref('stg_ef3__staffs') }} | ||
), | ||
flattened as ( | ||
select | ||
tenant_code, | ||
api_year, | ||
k_staff, | ||
{{ extract_descriptor('value:raceDescriptor::string') }} as race | ||
from stage_staffs | ||
, lateral flatten(input=>v_races) | ||
) | ||
select * from flattened | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ls/staging/edfi_3/stage/stg_ef3__staff_education_organization_employment_associations.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
with base_staff_ed_org_employ as ( | ||
select * from {{ ref('base_ef3__staff_education_organization_employment_associations') }} | ||
where not is_deleted | ||
), | ||
keyed as ( | ||
select | ||
{{ gen_skey('k_staff') }}, | ||
{{ edorg_ref() }}, | ||
api_year as school_year, | ||
base_staff_ed_org_employ.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from base_staff_ed_org_employ | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by= 'tenant_code, api_year, ed_org_id, employment_status, hire_date, staff_unique_id', | ||
order_by='api_year desc, pull_timestamp desc' | ||
) | ||
}} | ||
) | ||
select * from deduped |