From 48a2f0f19ba15227c4cf50f0464e707db12f087b Mon Sep 17 00:00:00 2001 From: "allison@code.org" Date: Fri, 19 Jul 2024 17:12:30 +0000 Subject: [PATCH] deprecate dim_teacher_schools --- .../marts/teachers/dim_teacher_schools.sql | 61 ------------------- 1 file changed, 61 deletions(-) delete mode 100644 dbt/models/marts/teachers/dim_teacher_schools.sql diff --git a/dbt/models/marts/teachers/dim_teacher_schools.sql b/dbt/models/marts/teachers/dim_teacher_schools.sql deleted file mode 100644 index 90f8333a..00000000 --- a/dbt/models/marts/teachers/dim_teacher_schools.sql +++ /dev/null @@ -1,61 +0,0 @@ -{# Notes: -Design: 1 row per teacher, school year -Logic: For every school year, assign the latest school the teacher was associated with in that school year. -#} - -with -user_school_infos as ( - select * - from {{ ref('stg_dashboard_pii__user_school_infos') }} -), - -school_infos as ( - select * - from {{ ref('stg_dashboard__school_infos') }} -), - -school_years as ( - select * - from {{ ref('int_school_years') }} -), - -user_school_infos_sy as ( - select - usi.user_id, - sy.school_year as started_at_sy, - row_number() over ( - partition by - usi.user_id, - sy.school_year - order by usi.started_at - desc) as row_num, - - usi.school_info_id, - si.school_id, - usi.started_at, - usi.ended_at - from user_school_infos usi - left join school_infos si - on usi.school_info_id = si.school_info_id - join school_years sy - on usi.started_at - between sy.started_at - and sy.ended_at -), - -final as ( - select - usi_sy.user_id as teacher_id, - usi_sy.school_info_id, - usi_sy.school_id, - - usi_sy.started_at_sy, - usi_sy.started_at, - usi_sy.ended_at - from user_school_infos_sy as usi_sy - where row_num = 1 - order by started_at_sy -) - -select * -from final \ No newline at end of file