forked from edanalytics/edu_edfi_source
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: create base tpdm/edfi_3 models iteration 2, add staging models
- Loading branch information
Vasili Zakharko
committed
Jul 25, 2024
1 parent
8026cc8
commit f9f888d
Showing
5 changed files
with
93 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
28 changes: 28 additions & 0 deletions
28
models/staging/edfi_3/stage/stg_ef3__school_year_types.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,28 @@ | ||
with school_year_types as ( | ||
select * from {{ ref('base_ef3__school_year_types') }} | ||
where not is_deleted | ||
), | ||
keyed as ( | ||
select | ||
{{ dbt_utils.surrogate_key( | ||
[ | ||
'tenant_code', | ||
'api_year', | ||
'lower(school_year)', | ||
'lower(current_school_year)' | ||
] | ||
)}} as k_school_year_types, | ||
api_year as school_year, | ||
school_year_types.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from school_year_types | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by='k_school_year_types', | ||
order_by='pull_timestamp desc' | ||
) | ||
}} | ||
) |
28 changes: 28 additions & 0 deletions
28
models/staging/edfi_3/stage/stg_ef3__staff_absence_events.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,28 @@ | ||
with staff_absence_events as ( | ||
select * from {{ ref('base_ef3__staff_absence_events') }} | ||
), | ||
keyed as ( | ||
select | ||
{{ dbt_utils.surrogate_key( | ||
[ | ||
'tenant_code', | ||
'lower(absence_event_category)', | ||
'lower(survey_identifier)', | ||
'lower(namespace)', | ||
'lower(course_code)' | ||
] | ||
) }} as k_staff_absence_events, | ||
staff_absence_events.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from staff_absence_events | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by='k_staff_absence_events', | ||
order_by='api_year desc, pull_timestamp desc' | ||
) | ||
}} | ||
) | ||
select * from deduped |
29 changes: 29 additions & 0 deletions
29
models/staging/edfi_3/stage/stg_ef3__survey_course_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,29 @@ | ||
with base_survey_course_associations as ( | ||
select * from {{ ref('base_ef3__survey_course_associations') }} | ||
where not is_deleted | ||
), | ||
keyed as ( | ||
select | ||
{{ gen_skey('k_survey') }}, | ||
{{ gen_skey('k_course') }}, | ||
{{ dbt_utils.surrogate_key( | ||
[ | ||
'tenant_code', | ||
'lower(education_organization_id)', | ||
'lower(event_date)' | ||
] | ||
) }} as k_survey_course_associations, | ||
base_survey_course_associations.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from base_survey_course_associations | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by='k_survey, k_course, entry_date, k_survey_course_associations', | ||
order_by='pull_timestamp desc' | ||
) | ||
}} | ||
) | ||
select * from deduped |