-
Notifications
You must be signed in to change notification settings - Fork 1
Add parents #17
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
Add parents #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| {# | ||
| This "bridge" table is used by both int_users_parent and int_users_student | ||
| to link students and parents (via the OneRoster agentSourcedIds). | ||
| #} | ||
| {{ | ||
| config( | ||
| materialized = 'ephemeral' | ||
| ) | ||
| }} | ||
|
|
||
| with dim_parent as ( | ||
| select * exclude tenant_code from {{ ref('dim_parent') }} | ||
| where school_year = {{ var('oneroster:active_school_year')}} | ||
| ), | ||
| dim_student as ( | ||
| select * exclude tenant_code from {{ ref('dim_student') }} | ||
| ), | ||
| student_parent as ( | ||
| select * from {{ ref('fct_student_parent_association') }} | ||
| where school_year = {{ var('oneroster:active_school_year')}} | ||
| ) | ||
| select | ||
| student_parent.k_student, | ||
| {{ gen_sourced_id('student') }} as student_sourced_id, | ||
| student_parent.k_parent, | ||
| {{ gen_sourced_id('parent') }} as parent_sourced_id | ||
| from dim_student | ||
| join student_parent | ||
| on student_parent.k_student = dim_student.k_student | ||
| join dim_parent | ||
| on dim_parent.k_parent = student_parent.k_parent |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| {{ | ||
| config( | ||
| materialized = 'ephemeral', | ||
| ) | ||
| }} | ||
|
|
||
| with dim_parent as ( | ||
| select * from {{ ref('dim_parent') }} | ||
| where school_year = {{ var('oneroster:active_school_year')}} | ||
| ), | ||
| student_school as ( | ||
| select * exclude tenant_code from {{ ref('fct_student_school_association') }} | ||
| where school_year = {{ var('oneroster:active_school_year')}} | ||
| ), | ||
| dim_school as ( | ||
| select * exclude tenant_code from {{ ref('dim_school') }} | ||
| ), | ||
| parent_email as ( | ||
| {{ | ||
| edu_wh.row_pluck(ref('stg_ef3__contacts__emails'), | ||
| key='k_contact', | ||
| column='email_type', | ||
| preferred=var('oneroster:parent_email_type', 'Home/Personal'), | ||
| where='(do_not_publish is null or not do_not_publish)') | ||
| }} | ||
| ), | ||
| parent_telephone as ( | ||
| {{ | ||
| edu_wh.row_pluck(ref('stg_ef3__contacts__telephones'), | ||
| key='k_contact', | ||
| column='phone_number_type', | ||
| preferred=var('oneroster:parent_telephone_type', 'Mobile'), | ||
| where='(do_not_publish is null or not do_not_publish)') | ||
| }} | ||
| ), | ||
|
|
||
| parent_orgs as ( | ||
|
tomreitz marked this conversation as resolved.
|
||
| select | ||
| dim_parent.k_parent, | ||
| dim_school.k_lea, | ||
| dim_school.k_school, | ||
| dim_school.school_id, | ||
| {{ gen_sourced_id('school') }} as sourced_id, | ||
| student_school.is_primary_school, | ||
| student_school.entry_date, | ||
| dim_parent.tenant_code | ||
| from dim_parent | ||
| join {{ ref('or1_1__int_student_parent_bridge') }} student_parent_bridge | ||
| on dim_parent.k_parent = student_parent_bridge.k_parent | ||
| join student_school | ||
| on student_school.k_student = student_parent_bridge.k_student | ||
| join dim_school | ||
| on student_school.k_school = dim_school.k_school | ||
| ), | ||
| parent_orgs_agg as ( | ||
| select | ||
| k_parent, | ||
| listagg(distinct sourced_id, ',') as orgs | ||
| from parent_orgs | ||
| group by all | ||
| ), | ||
|
|
||
| parent_students as ( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OneRoster has
This CTE constructs the array of sourcedIds of students for each parent; a similar CTE was added to |
||
| select | ||
| dim_parent.k_parent, | ||
| student_sourced_id as sourced_id, | ||
| dim_parent.tenant_code | ||
| from dim_parent | ||
| join {{ ref('or1_1__int_student_parent_bridge') }} student_parent_bridge | ||
| on dim_parent.k_parent = student_parent_bridge.k_parent | ||
| ), | ||
| parent_students_agg as ( | ||
| select | ||
| k_parent, | ||
| listagg(distinct sourced_id, ',') as students | ||
| from parent_students | ||
| group by all | ||
| ), | ||
|
|
||
| parent_keys as ( | ||
| select | ||
| k_parent, | ||
| {{ gen_sourced_id('parent') }} as sourced_id, | ||
| {{ gen_natural_key('parent') }} as natural_key | ||
| from dim_parent | ||
| ), | ||
| formatted as ( | ||
| select | ||
| parent_keys.sourced_id as "sourcedId", | ||
| null::string as "status", | ||
| null::date as "dateLastModified", | ||
| true as "enabledUser", | ||
| parent_orgs_agg.orgs as "orgSourcedIds", | ||
| 'parent' as "role", | ||
| parent_email.email_address as "username", | ||
| null::string as "userIds", | ||
| dim_parent.first_name as "givenName", | ||
| dim_parent.last_name as "familyName", | ||
| dim_parent.middle_name as "middleName", | ||
| dim_parent.parent_unique_id as "identifier", | ||
| parent_email.email_address as "email", | ||
| null::string as "sms", | ||
| parent_telephone.phone_number as "phone", | ||
|
tomreitz marked this conversation as resolved.
|
||
| parent_students_agg.students as "agentSourcedIds", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤨 i truly don't know |
||
| null::string as "grades", | ||
| null::string as "password", | ||
| parent_keys.natural_key as "metadata.edu.natural_key", | ||
| null::string as "metadata.edu.staff_classfication", | ||
| null::string as "metadata.edu.primary_school", | ||
| dim_parent.tenant_code | ||
| from dim_parent | ||
| join parent_keys | ||
| on dim_parent.k_parent = parent_keys.k_parent | ||
| left join parent_orgs_agg | ||
| on dim_parent.k_parent = parent_orgs_agg.k_parent | ||
| left join parent_students_agg | ||
| on dim_parent.k_parent = parent_students_agg.k_parent | ||
| left join parent_email | ||
| on dim_parent.k_parent = parent_email.k_contact | ||
| left join parent_telephone | ||
| on dim_parent.k_parent = parent_telephone.k_contact | ||
| ) | ||
| select * from formatted | ||
Uh oh!
There was an error while loading. Please reload this page.