Skip to content

Commit

Permalink
Create base TPDM models
Browse files Browse the repository at this point in the history
  • Loading branch information
zaharenka committed Jul 8, 2024
1 parent b4cd87e commit 31ff611
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 0 deletions.
27 changes: 27 additions & 0 deletions models/staging/tpdm/base/_tpdm__base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,30 @@ models:
- name: base_tpdm__educator_preparation_programs
config:
tags: ['tpdm']
- name: base_tpdm__student_academic_records
config:
tags: ['tpdm']
- name: base_tpdm__survey_response_person_target_associations
config:
tags: ['tpdm']
- name: base_tpdm__survey_responses
config:
tags: ['tpdm']
- name: base_tpdm__persons
config:
tags: ['tpdm']
- name: base_tpdm__survey_section_responses
config:
tags: ['tpdm']
- name: base_tpdm__post_secondary_institutions
config:
tags: ['tpdm']
- name: base_tpdm__schools
config:
tags: ['tpdm']
- name: base_tpdm__education_organizations
config:
tags: ['tpdm']
- name: base_tpdm__candidate_educator_preparation_program_associations
config:
tags: ['tpdm']
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
with candidate_educator_preparation_program_associations as (
{{ source_edfi3('candidate_educator_preparation_program_associations') }}
),
renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,

v:id::string as record_guid,
v:candidateReference:candidateIdentifier::string as candidate_id,
v:educatorPreparationProgramReference:programId::string as program_id,
v:applicationReference:applicationIdentifier::string as application_id,
v:beginDate::date as begin_date,
v:endDate::date as end_date,
-- descriptors
{{ extract_descriptor('v:reasonExitedDescriptor::string') }} as reason_exited,
{{ extract_descriptor('v:eppProgramPathwayDescriptor::string') }} as epp_program_pathway,
-- unnested lists
v:identificationCodes as v_identification_codes,
v:candidateIndicators as v_candidate_indicators,
v:degreeSpecializations as v_degree_specializations,
v:cohortYears as v_cohort_years,
-- references
v:candidateReference as candidate_reference,
v:educatorPreparationProgramReference as educator_preparation_program_reference,
v:applicationReference as application_reference
from candidate_educator_preparation_program_associations
)

select * from renamed
31 changes: 31 additions & 0 deletions models/staging/tpdm/base/base_tpdm__education_organizations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
with education_organizations as (
{{ source_edfi3('education_organizations') }}
),
renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,

v:id::string as record_guid,
v:educationOrganizationId:int as education_organization_id,
v:nameOfInstitution::string as name_of_institution,
v:shortNameOfInstitution::string as short_name_of_institution,
v:webSite::string as web_site,
-- descriptors
{{ extract_descriptor('v:operationalStatusDescriptor::string') }} as operational_tatus,
-- unnested lists
v:identificationCodes as identification_codes,
v:categories as categories,
v:addresses as addresses,
v:internationalAddresses as international_addresses,
v:institutionTelephones as institution_telephones,
v:indicators as indicators
from education_organization
)

select * from renamed
20 changes: 20 additions & 0 deletions models/staging/tpdm/base/base_tpdm__persons.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
with persons as (
{{ source_edfi3('persons') }}
),
renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,

v:personId::string as person_id,
-- descriptors
{{ extract_descriptor('v:sourceSystemDescriptor::string') }} as source_system
from persons
)

select * from
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
with post_secondary_institutions as (
{{ source_edfi3('post_secondary_institutions') }}
),
renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,

v:id::string as record_guid,
v:postSecondaryInstitutionId::int as post_secondary_institution_id,
-- descriptors
{{ extract_descriptor('v:postSecondaryInstitutionLevelDescriptor::string')}} as post_secondary_institution_level,
{{ extract_descriptor('v:administrativeFundingControlDescriptor::string')}} as administrative_funding_control,
{{ extract_descriptor('v:federalLocaleCodeDescriptor::string')}} as federal_locale_code,
-- unflattened lists
v:mediumOfInstructions as v_medium_of_instructions
from student_academic_records
)

select * from renamed
37 changes: 37 additions & 0 deletions models/staging/tpdm/base/base_tpdm__schools.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
with schools as (
{{ source_edfi3('schools') }}
),
renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,

v:id::string as record_guid,
v:schoolId::int as school_id,
v:localEducationAgencyReference:localEducationAgencyId::int as lea_id,
-- descriptors
{{ extract_descriptor('v:schoolTypeDescriptor::string') }} as school_type,
{{ extract_descriptor('v:postSecondaryInstitutionLevelDescriptor::string')}} as post_secondary_institution_level,
{{ extract_descriptor('v:administrativeFundingControlDescriptor::string')}} as administrative_funding_control,
{{ extract_descriptor('v:federalLocaleCodeDescriptor::string')}} as federal_locale_code,
{{ extract_descriptor('v:internetAccessDescriptor::string') }} as internet_access,
{{ extract_descriptor('v:charterApprovalAgencyTypeDescriptor::string') }} as charter_approval_agency,
{{ extract_descriptor('v:magnetSpecialProgramEmphasisSchoolDescriptor::string') }} as magnet_type,
{{ extract_descriptor('v:titleIPartASchoolDesignationDescriptor::string') }} as title_i_part_a_school_designation,
{{ extract_descriptor('v:charterStatusDescriptor::string') }} as charter_status,
{{ extract_descriptor('v:accreditationStatusDescriptor::string') }} as accreditation_status,
-- references
v:localEducationAgencyReference as local_education_agency_reference,
-- unflattened lists
v:gradeLevels as v_grade_levels,
v:schoolCategories as v_school_categories,
v:mediumOfInstructions as v_medium_of_instructions
from student_academic_records
)

select * from renamed
40 changes: 40 additions & 0 deletions models/staging/tpdm/base/base_tpdm__student_academic_records.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
with student_academic_records as (
{{ source_edfi3('student_academic_records') }}
),

renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,
v:id::string as record_guid,

v:studentReference:studentUniqueId::string as student_unique_id,
v:educationOrganizationReference:educationOrganizationId::int as ed_org_id,
v:educationOrganizationReference:link:rel::string as ed_org_type,
v:schoolYearTypeReference:schoolYear::int as school_year,
v:projectedGraduationDate::date as projected_graduation_date,
-- descriptors
{{ extract_descriptor('v:termDescriptor::string') }} as term,
-- unflattened lists
v:cumulativeEarnedCredits as v_cumulative_earned_credits,
v:cumulativeAttemptedCredits as v_cumulative_attempted_credits,
v:classRanking as v_class_ranking,
v:academicHonors as v_academic_honors,
v:recognitions as v_recognitions,
v:sessionEarnedCredits as v_session_earned_credits,
v:sessionAttemptedCredits as v_session_attempted_credits,
v:gradePointAverages as v_grade_point_averages,
v:diplomas as v_diplomas,
v:reportCards as v_report_cards,
-- references
v:studentReference as student_reference,
v:educationOrganizationReference as ed_org_reference
from student_academic_records
)

select * from renamed
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
with survey_response_person_target_associations as (
{{ source_edfi3('survey_response_person_target_associations') }}
),
renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,

v:id::string as record_guid,
v:surveyResponseReference:surveyResponseIdentifier::string as survey_response_id,
v:personReference:personId:string as person_id,
-- references
v:surveyResponseReference as survey_response_reference,
v:personReference as person_reference
from survey_response_person_target_associations
)

select * from renamed
33 changes: 33 additions & 0 deletions models/staging/tpdm/base/base_tpdm__survey_responses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
with survey_responses as (
{{ source_edfi3('survey_responses') }}
),
renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,

v:id::string as record_guid,
v:surveyReference:surveyIdentifier::string as survey_id,
v:surveyReference:namespace::string as namespace,
v:surveyResponseIdentifier::string as survey_response_id,
v:studentReference:studentUniqueId as student_unique_id,
v:electronicMailAddress::string as electronic_mail_address,
v:fullName::string as full_name,
v:location::string as location,
v:responseDate::date as response_date,
v:responseTime::int as completion_time_seconds,
--references
v:surveyReference as survey_reference,
v:studentReference as student_reference,
v:staffReference as staff_reference,
v:contactReference as contact_reference,
-- lists
v:surveyLevels as v_survey_levels
from survey_responses
)
select * from renamed
26 changes: 26 additions & 0 deletions models/staging/tpdm/base/base_tpdm__survey_section_responses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
with base_tpdm__survey_section_responses as (
{{ source_edfi3('base_tpdm__survey_section_responses') }}
),
renamed as (
select
tenant_code,
api_year,
pull_timestamp,
last_modified_timestamp,
file_row_number,
filename,
is_deleted,

v:id::string as record_guid,
v:surveyReference:surveyIdentifier::string as survey_id,
v:surveyResponseReference:surveyResponseIdentifier::string as survey_response_id,
v:surveySectionReference:surveySectionTitle::string as survey_section_title,
v:sectionRating:int as section_rating,
-- references
v:surveySectionReference as survey_section_reference,
v:surveyResponseReference as survey_response_reference,
v:surveyReference as survey_reference
from base_tpdm__survey_section_responses
)

select * from renamed

0 comments on commit 31ff611

Please sign in to comment.