Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased
## New features
- Add `bld_ef3__student__other_names` and conditional code in `dim_student` to pull into columns, if configured in dbt var `'edu:stu_demos:other_names'`.
## Under the hood
## Fixes

Expand Down
31 changes: 31 additions & 0 deletions models/build/edfi_3/students/bld_ef3__student__other_names.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{# otherName properties pulled from Ed-Fi Data Handbook (v5.0.0)
https://edfidocs.blob.core.windows.net/$web/handbook/v5.0/index.html#/OtherName82adcecf-8e39-4f24-a5a6-3c32964693c3 #}
{%- set name_type_list = ['personal_title_prefix', 'first_name', 'middle_name', 'last_surname', 'generation_code_suffix']-%}

with stg_other_names as (
select * from {{ ref('stg_ef3__students__other_names') }}
),
widened as (
select
tenant_code,
api_year,
k_student,
k_student_xyear
{%- if not is_empty_model('stg_ef3__students__other_names') -%},
{%- for name_type in name_type_list -%}
{{ ea_pivot(
column='other_name_type',
values=dbt_utils.get_column_values(ref('stg_ef3__students__other_names'),'other_name_type'),
agg='min',
suffix='_' ~ name_type,
then_value=name_type,
else_value='null',
)}}
{%- if not loop.last -%},{%- endif-%}
{%- endfor-%}
{%- endif %}
from stg_other_names
group by all

)
select * from widened
16 changes: 15 additions & 1 deletion models/core_warehouse/dim_student.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
{% set custom_homeless_program_agg_indicators = var('edu:homeless:custom_program_agg_indicators', None) %}
{% set custom_language_instruction_program_agg_indicators = var('edu:language_instruction:custom_program_agg_indicators', None) %}
{% set custom_title_i_program_agg_indicators = var('edu:title_i:custom_program_agg_indicators', None) %}

{% set other_name_types = var('edu:stu_demos:other_names', None) %}
{%- set name_type_list = ['personal_title_prefix', 'first_name', 'middle_name', 'last_surname', 'generation_code_suffix']-%}

with stg_student as (
select * from {{ ref('stg_ef3__students') }}
Expand Down Expand Up @@ -53,6 +54,9 @@ stu_grade as (
stu_cohort_year as (
select * from {{ ref('bld_ef3__student_cohort_years')}}
),
stu_other_names as (
select * from {{ ref('bld_ef3__student__other_names') }}
),

-- student programs
{% if var('src:program:special_ed:enabled', True) %}
Expand Down Expand Up @@ -191,6 +195,14 @@ formatted as (
{%- endfor -%}
{%- endif %}

-- other name types
{% if other_name_types is not none and other_name_types | length -%}
{%- for type in other_name_types -%}
{%- for name_type in name_type_list -%}
stu_other_names.{{dbt_utils.slugify(type)}}_{{name_type}},
{%- endfor -%}
{%- endfor -%}
{%- endif -%}
-- add indicator of most recent demographic entry
stg_student.api_year = max(stg_student.api_year) over(partition by stg_student.k_student_xyear) as is_latest_record,

Expand Down Expand Up @@ -222,6 +234,8 @@ formatted as (
and stg_student.api_year = stu_grade.school_year
left join stu_cohort_year
on stu_demos.k_student = stu_cohort_year.k_student
left join stu_other_names
on stu_demos.k_student = stu_other_names.k_student

-- student programs
{% if var('src:program:special_ed:enabled', True) %}
Expand Down