Skip to content

Commit

Permalink
Merge pull request #2384 from TEAMSchools/psatnmsqt
Browse files Browse the repository at this point in the history
Psatnmsqt
  • Loading branch information
cbini authored Jan 17, 2025
2 parents 4592d08 + 86b99a3 commit a4e7cca
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
select psat.*, xw.powerschool_student_number,
select
psat.*,
xw.powerschool_student_number,
case
psat.test_type
when 'PSAT89'
then 'psat89'
when 'PSATNM'
then 'psatnmsqt'
when 'PSAT10'
then 'psat10'
end as test_name,
from {{ ref("stg_collegeboard__psat") }} as psat
left join
{{ ref("stg_collegeboard__id_crosswalk") }} as xw
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
with
psat as (
select
cb_id,
powerschool_student_number as local_student_id,

score,

concat(
test_name, '_', regexp_extract(score_type, r'^[^_]+_(.+)')
) as score_type,

safe_cast(latest_psat_date as date) as `date`,

case
test_type
when 'PSATNM'
then 'PSAT NMSQT'
when 'PSAT89'
then 'PSAT 8/9'
when 'PSAT10'
then 'PSAT10'
end as test_type,

case
score_type
when 'latest_psat_total'
then 'Composite'
when 'latest_psat_math_section'
then 'Math'
when 'latest_psat_ebrw'
then 'EBRW'
end as test_subject,

from
{{ ref("int_collegeboard__psat") }} unpivot (
score for score_type
in (latest_psat_total, latest_psat_math_section, latest_psat_ebrw)
)
)

select
cb_id,
local_student_id,
`date`,
score_type,
score,
test_type,
test_subject,

row_number() over (
partition by local_student_id, test_type, score_type order by score desc
) as rn_highest,
from psat
Original file line number Diff line number Diff line change
Expand Up @@ -147,47 +147,30 @@ with

select
safe_cast(local_student_id as string) as contact,

test_name as scope,

test_date,
test_type as scope,
date as test_date,
score as scale_score,
rn_highest,

'Official' as test_type,

concat(
format_date('%b', test_date), ' ', format_date('%g', test_date)
format_date('%b', date), ' ', format_date('%g', date)
) as administration_round,

test_subject as subject_area,

case
score_type
when 'psat_total_score'
then 'Composite'
when 'psat_math_section_score'
then 'Math'
when 'psat_eb_read_write_section_score'
then 'EBRW'
end as subject_area,
case
score_type
when 'psat_eb_read_write_section_score'
then 'ENG'
when 'psat_math_section_score'
then 'MATH'
else 'NA'
test_subject when 'EBRW' then 'ENG' when 'Math' then 'MATH' else 'NA'
end as course_discipline,

academic_year as test_academic_year,
{{
date_to_fiscal_year(
date_field="date", start_month=7, year_source="start"
)
}} as test_academic_year,

from {{ ref("int_illuminate__psat_unpivot") }}
where
score_type in (
'psat_eb_read_write_section_score',
'psat_math_section_score',
'psat_total_score'
)
and academic_year = {{ var("current_academic_year") }}
from {{ ref("int_collegeboard__psat_unpivot") }}
)

select
Expand Down

0 comments on commit a4e7cca

Please sign in to comment.