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.
Merge pull request #10 from Unicon/create-tpdm-models-iteration-2
Create base/stage models (iteration)
- Loading branch information
Showing
34 changed files
with
865 additions
and
35 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
with people as ( | ||
{{ source_edfi3('people') }} | ||
), | ||
renamed as ( | ||
select | ||
tenant_code, | ||
api_year, | ||
pull_timestamp, | ||
last_modified_timestamp, | ||
file_row_number, | ||
filename, | ||
is_deleted, | ||
|
||
v:id::string as record_guid, | ||
-- identity components | ||
v:personId::int as person_id, | ||
{{ extract_descriptor('v:sourceSystemDescriptor::string') }} as source_system | ||
from people | ||
) | ||
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
22 changes: 22 additions & 0 deletions
22
models/staging/edfi_3/base/base_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,22 @@ | ||
with school_year_types as ( | ||
{{ source_edfi3('school_year_types') }} | ||
), | ||
renamed as ( | ||
select | ||
tenant_code, | ||
api_year, | ||
pull_timestamp, | ||
last_modified_timestamp, | ||
filename, | ||
file_row_number, | ||
is_deleted, | ||
|
||
v:id::string as record_guid, | ||
-- identity components | ||
v:schoolYear::string as school_year, | ||
-- non-identity components | ||
v:currentSchoolYear::string as current_school_year, | ||
v:schoolYearDescription::string as school_year_description | ||
from school_year_types | ||
) | ||
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
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
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 credentials as ( | ||
select * from {{ ref('base_tpdm__credentials') }} | ||
where not is_deleted | ||
), | ||
keyed as ( | ||
select | ||
{{ dbt_utils.surrogate_key( | ||
['tenant_code', | ||
'api_year', | ||
'lower(namespace)', | ||
'lower(person_id)', | ||
'lower(source_system)', | ||
'lower(survey_id)', | ||
'lower(survey_response_id)'] | ||
) }} as k_credential, | ||
{{ gen_skey('k_student_academic_record')}}, | ||
credentials.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from credentials | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by='k_credential', | ||
order_by='pull_timestamp desc') | ||
}} | ||
) | ||
select * from deduped |
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,25 @@ | ||
with base_people as ( | ||
select * from {{ ref('base_ef3__people') }} | ||
where not is_deleted | ||
), | ||
keyed as ( | ||
select | ||
{{ dbt_utils.surrogate_key( | ||
['tenant_code', | ||
'api_year', | ||
'person_id', | ||
'lower(source_system)'] | ||
) }} as k_person, | ||
base_people.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from base_people | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by='k_person', | ||
order_by='pull_timestamp desc') | ||
}} | ||
) | ||
select * from deduped |
24 changes: 24 additions & 0 deletions
24
models/staging/edfi_3/stage/stg_ef3__post_secondary_institutions.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,24 @@ | ||
with post_secondary_institutions as ( | ||
select * from {{ ref('base_tpdm__post_secondary_institutions') }} | ||
where not is_deleted | ||
), | ||
keyed as ( | ||
select | ||
{{ dbt_utils.surrogate_key( | ||
['tenant_code', | ||
'api_year', | ||
'post_secondary_institution_id'] | ||
) }} as k_post_secondary_institution, | ||
post_secondary_institutions.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from post_secondary_institutions | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by='k_post_secondary_institution', | ||
order_by='pull_timestamp desc') | ||
}} | ||
) | ||
select * from deduped |
24 changes: 24 additions & 0 deletions
24
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,24 @@ | ||
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)'] | ||
) }} as k_school_year_type, | ||
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_type', | ||
order_by='pull_timestamp desc') | ||
}} | ||
) | ||
select * from deduped |
28 changes: 28 additions & 0 deletions
28
models/staging/edfi_3/stage/stg_ef3__survey_section_responses.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 survey_section_responses as ( | ||
select * from {{ ref('base_ef3__survey_section_responses') }} | ||
where not is_deleted | ||
), | ||
keyed as ( | ||
select | ||
{{ dbt_utils.surrogate_key( | ||
['tenant_code', | ||
'api_year', | ||
'lower(survey_id)', | ||
'lower(namespace)', | ||
'lower(survey_section_title)'] | ||
) }} as k_survey_section_response, | ||
{{ gen_skey('k_survey_response') }}, | ||
{{ gen_skey('k_survey_section') }}, | ||
survey_section_responses.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from survey_section_responses | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by='k_survey_section_response', | ||
order_by='pull_timestamp desc') | ||
}} | ||
) | ||
select * from deduped |
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,27 @@ | ||
with survey_sections as ( | ||
select * from {{ ref('base_ef3__survey_sections') }} | ||
where not is_deleted | ||
), | ||
keyed as ( | ||
select | ||
{{ dbt_utils.surrogate_key( | ||
['tenant_code', | ||
'api_year', | ||
'lower(survey_id)', | ||
'lower(namespace)', | ||
'lower(survey_section_title)'] | ||
) }} as k_survey_section, | ||
{{ gen_skey('k_survey') }}, | ||
survey_sections.* | ||
{{ extract_extension(model_name=this.name, flatten=True) }} | ||
from survey_sections | ||
), | ||
deduped as ( | ||
{{ | ||
dbt_utils.deduplicate( | ||
relation='keyed', | ||
partition_by='k_survey_section', | ||
order_by='pull_timestamp desc') | ||
}} | ||
) | ||
select * from deduped |
Oops, something went wrong.