@@ -13,7 +13,7 @@ student_school as (
1313 where school_year = {{ var(' oneroster:active_school_year' )}}
1414),
1515dim_school as (
16- select * from {{ ref(' dim_school' ) }}
16+ select * exclude tenant_code from {{ ref(' dim_school' ) }}
1717),
1818grade_level_xwalk as (
1919 select * from {{ ref(' xwalk_oneroster_grade_levels' ) }}
@@ -44,6 +44,8 @@ student_orgs as (
4444 dim_school .k_school ,
4545 dim_school .school_id ,
4646 {{ gen_sourced_id(' school' ) }} as sourced_id,
47+ student_school .is_primary_school ,
48+ student_school .entry_date ,
4749 student_school .tenant_code
4850 from student_school
4951 join dim_school
@@ -54,8 +56,8 @@ student_orgs_agg as (
5456 k_student,
5557 listagg(distinct sourced_id, ' ,' ) as orgs,
5658 -- create columns for primary school extension
57- max_by(sourced_id, is_primary_school, 1 )[0 ] as primary_school_sourced_id,
58- max_by(sourced_id, entry_date, 1 )[0 ] as latest_school_sourced_id
59+ max_by(sourced_id, is_primary_school, 1 )[0 ]::string as primary_school_sourced_id,
60+ max_by(sourced_id, entry_date, 1 )[0 ]::string as latest_school_sourced_id
5961 from student_orgs
6062 group by all
6163),
@@ -97,10 +99,8 @@ formatted as (
9799 on dim_student .k_student = student_orgs_agg .k_student
98100 left join user_ids
99101 on dim_student .k_student = user_ids .k_student
100- and student_orgs_agg .k_lea = user_ids .k_lea
101- left join student_email
102- on dim_student .k_student = student_email .k_student
103- and student_orgs_agg .k_lea = student_email .k_lea
102+ left join student_email
103+ on dim_student .k_student = student_email .k_student
104104 left join grade_level_xwalk
105105 on dim_student .grade_level = grade_level_xwalk .edfi_grade_level
106106)
0 commit comments