Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base models #11

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions models/staging/edfi_3/base/_edfi_3__base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,33 @@ models:
config:
tags: ['assessment']
enabled: "{{ var('src:domain:assessment:enabled', True) }}"
- name: base_ef3__open_staff_positions
config:
tags: ['core']
- name: base_ef3__organization_departments
config:
tags: ['core']
- name: base_ef3__parents
config:
tags: ['core']
- name: base_ef3__payrolls
config:
tags: ['core']
- name: base_ef3__people
config:
tags: ['core']
- name: base_ef3__post_secondary_events
config:
tags: ['core']
- name: base_ef3__report_cards
config:
tags: ['core']
- name: base_ef3__restraint_events
config:
tags: ['core']
- name: base_ef3__rubric_dimensions
config:
tags: ['core']
- name: base_ef3__programs
config:
tags: ['core']
Expand Down
37 changes: 37 additions & 0 deletions models/staging/edfi_3/base/base_ef3__open_staff_positions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
with open_staff_positions as (
{{ source_edfi3('open_staff_positions') }}
),
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:educationOrganizationReference:educationOrganizationId::int as ed_org_id,
v:positionTitle::string as position_title,
v:requisitionNumber::string as requisition_number,
v:datePosted::date as date_posted,
v:datePostingRemoved::date as date_posting_removed,
case
when array_size(v:academicSubjects) > 1
then False
else True
end as is_single_subject_identifier,
-- descriptors
{{ extract_descriptor('v:employmentStatusDescriptor::string') }} as employment_status,
{{ extract_descriptor('v:staffClassificationDescriptor::string') }} as staff_classification,
{{ extract_descriptor('v:programAssignmentDescriptor::string') }} as program_assignment,
{{ extract_descriptor('v:postingResultDescriptor::string') }} as posting_result,
-- references
v:educationOrganizationReference as education_organization,
-- unflattened lists
v:academicSubjects as v_academic_subjects,
v:instructionalGradeLevels as v_instructional_grade_levels
from open_staff_positions
)
select * from renamed
34 changes: 34 additions & 0 deletions models/staging/edfi_3/base/base_ef3__organization_departments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
with organization_departments as (
{{ source_edfi3('organization_departments') }}
),
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:parentEducationOrganizationReference:educationOrganizationId::int as ed_org_id,
v:organizationDepartmentId::int as ed_org_department_id,
v:nameOfInstitution::int as name_of_institution,
v:shortNameOfInstitution::int as short_name_of_institution,
v:webSite::int as web_site,
-- descriptors
{{ extract_descriptor('v:academicSubjectDescriptor::string') }} as academic_subject,
{{ extract_descriptor('v:operationalStatusDescriptor::string') }} as operational_status,
--references
v:parentEducationOrganizationReference as education_organization,
-- unflattened lists
v:categories as v_categories,
v:addresses as v_addresses,
v:identificationCodes as v_identification_codes,
v:indicators as v_indicators,
v:institutionTelephones as v_institution_telephones,
v:internationalAddresses as v_international_addresses
from organization_departments
)
select * from renamed
25 changes: 25 additions & 0 deletions models/staging/edfi_3/base/base_ef3__payrolls.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
with payrolls as (
{{ source_edfi3('payrolls') }}
),
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:accountReference:educationOrganizationId::int as ed_org_id,
v:accountReference:accountIdentifier::string as account_id,
v:staffReference:staffUniqueId::string as staff_unique_id,
v:asOfDate::date as as_of_date,
v:amountToDate::int as amount_to_date,
-- references
v:accountReference as account,
v:staffReference as staff
from payrolls
)
select * from renamed
20 changes: 20 additions & 0 deletions models/staging/edfi_3/base/base_ef3__people.sql
zaharenka marked this conversation as resolved.
Show resolved Hide resolved
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,
v:personId::int as person_id,
-- descriptors
{{ extract_descriptor('v:sourceSystemDescriptor::string') }} as source_system
from people
)
select * from renamed
25 changes: 25 additions & 0 deletions models/staging/edfi_3/base/base_ef3__post_secondary_events.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
with post_secondary_events as (
{{ source_edfi3('post_secondary_events') }}
),
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:postSecondaryInstitutionReference:postSecondaryInstitutionId::int as post_secondary_institution_id,
v:studentReference:studentUniqueId::int as student_unique_id,
v:eventDate::date as event_date,
-- descriptors
{{ extract_descriptor('v:postSecondaryEventCategoryDescriptor::string') }} as post_secondary_event_category,
-- references
v:postSecondaryInstitutionReference as post_secondary_institution,
v:studentReference as student
from post_secondary_events
)
select * from renamed
33 changes: 33 additions & 0 deletions models/staging/edfi_3/base/base_ef3__report_cards.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
with report_cards as (
{{ source_edfi3('report_cards') }}
),
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:educationOrganizationReference:educationOrganizationId::int as ed_org_id,
v:studentReference:studentUniqueId::int as student_unique_id,
v:gpaCumulative::int as gpa_cumulative,
v:gpaGivenGradingPeriod::int as gpa_given_grading_period,
v:numberOfDaysAbsent::int as number_of_days_absent,
v:numberOfDaysInAttendance::int as number_of_days_in_attendance,
v:numberOfDaysTardy::int as number_of_days_tardy,
-- references
v:gradingPeriodReference as grading_period
v:studentReference as student
v:educationOrganizationReference as education_organization_reference
-- unflattened lists
v:gradePointAverages as v_grade_point_averages,
v:grades as v_grades,
v:studentCompetencyObjectives as v_student_competency_objectives,
v:studentLearningObjectives as v_student_learning_objectives
from report_cards
)
select * from renamed
29 changes: 29 additions & 0 deletions models/staging/edfi_3/base/base_ef3__restraint_events.sql
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@holdorph said we don't need to create models for empty JSON files...but maybe i missed something

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but there is such API in docs

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
with restraint_events as (
{{ source_edfi3('restraint_events') }}
),
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:restraintEventIdentifier::string as record_guid,
v:schoolReference:schoolId::int as school_id,
v:studentReference:studentUniqueId::string as student_unique_id,
v:eventDate::date as event_date,
-- descriptors
{{ extract_descriptor('v:educationalEnvironmentDescriptor::string')}} as educational_environment,
-- references
v:schoolReference as school
v:studentReference as student
-- unflattened lists
v:programs as v_programs
v:reasons as v_reasons
from restraint_events
)
select * from renamed
25 changes: 25 additions & 0 deletions models/staging/edfi_3/base/base_ef3__rubric_dimensions.sql
maxalmazov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
with rubric_dimensions as (
{{ source_edfi3('rubric_dimensions') }}
),
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:evaluationElementReference:educationOrganizationId::int as ed_org_id,
v:rubricRating::int as rubric_rating,
v:dimensionOrder::int as dimension_order,
v:criterionDescription::string as criterion_description,
-- descriptors
{{ extract_descriptor('v:rubricRatingLevelDescriptor::string')}} as rubricRating_level,
--references
v:evaluationElementReference as evaluation_element
from rubric_dimensions
)
select * from renamed