|
| 1 | +with schools as ( |
| 2 | + {{ source_edfi3('schools') }} |
| 3 | +), |
| 4 | +renamed as ( |
| 5 | + select |
| 6 | + tenant_code, |
| 7 | + api_year, |
| 8 | + pull_timestamp, |
| 9 | + last_modified_timestamp, |
| 10 | + file_row_number, |
| 11 | + filename, |
| 12 | + is_deleted, |
| 13 | + v:id::string as record_guid, |
| 14 | + v:schoolId::integer as school_id, |
| 15 | + v:nameOfInstitution::string as school_name, |
| 16 | + v:shortNameOfInstitution::string as school_short_name, |
| 17 | + v:webSite::string as website, |
| 18 | + v:localEducationAgencyReference:localEducationAgencyId as lea_id, |
| 19 | + -- pull out school categories |
| 20 | + case |
| 21 | + when array_size(v:schoolCategories) = 1 |
| 22 | + then {{ extract_descriptor('v:schoolCategories[0]:schoolCategoryDescriptor::string') }} |
| 23 | + when array_size(v:schoolCategories) > 1 |
| 24 | + then 'Multiple Categories' |
| 25 | + else NULL |
| 26 | + end as school_category, |
| 27 | + -- descriptors |
| 28 | + {{ extract_descriptor('v:schoolTypeDescriptor::string') }} as school_type, |
| 29 | + {{ extract_descriptor('v:operationalStatusDescriptor::string') }} as operational_status, |
| 30 | + {{ extract_descriptor('v:administrativeFundingControlDescriptor::string') }} as administrative_funding_control, |
| 31 | + {{ extract_descriptor('v:internetAccessDescriptor::string') }} as internet_access, |
| 32 | + {{ extract_descriptor('v:titleIPartASchoolDesignationDescriptor::string') }} as title_i_part_a_school_designation, |
| 33 | + {{ extract_descriptor('v:charterStatusDescriptor::string') }} as charter_status, |
| 34 | + {{ extract_descriptor('v:charterApprovalAgencyTypeDescriptor::string') }} as charter_approval_agency, |
| 35 | + {{ extract_descriptor('v:magnetSpecialProgramEmphasisSchoolDescriptor::string') }} as magnet_type, |
| 36 | + -- references |
| 37 | + v:localEducationAgencyReference as local_education_agency_reference, |
| 38 | + -- unflattened lists |
| 39 | + v:addresses as v_addresses, |
| 40 | + v:educationOrganizationCategories as v_education_organization_categories, |
| 41 | + v:gradeLevels as v_grade_levels, |
| 42 | + v:identificationCodes as v_identification_codes, |
| 43 | + v:indicators as v_indicators, |
| 44 | + v:institutionTelephones as v_institution_telephones, |
| 45 | + v:internationalAddresses as v_international_addresses, |
| 46 | + v:schoolCategories as v_school_categories, |
| 47 | + |
| 48 | + -- edfi extensions |
| 49 | + v:_ext as v_ext |
| 50 | + from schools |
| 51 | +) |
| 52 | +select * from renamed |
0 commit comments