Skip to content
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

fct_stu_contact_information #115

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ vars:
'edu:stu_demos:hispanic_latino_code': Latinx
'edu:stu_demos:race_unknown_code': Unknown

# preferred student language use and column name
'edu:stu_language:language_use': Home language
'edu:stu_language:language_use_col_name': home_language
keenzarate213 marked this conversation as resolved.
Show resolved Hide resolved

# custom intersections of other demographic groupings
'edu:stu_demos:intersection_groups': Null
# custom data sources for student characteristics. must contain and be unique by `k_student`
Expand Down
3 changes: 3 additions & 0 deletions models/build/edfi_3/students/_edfi_3__students.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ models:
- name: bld_ef3__wide_ids_student
config:
tags: ['core']
- name: bld_ef3__choose_stu_languages
config:
tags: ['core']
15 changes: 15 additions & 0 deletions models/build/edfi_3/students/bld_ef3__choose_stu_language.sql
keenzarate213 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
with stu_language as (
select * from {{ ref('stg_ef3__stu_ed_org__languages') }}
),
choose_language as (
-- pick a single language use,
-- defaults to home language
{{
row_pluck('stu_language',
key='k_student',
column='language_use',
preferred=var('edu:stu_language:language_use')
)
}}
)
select * from choose_language
27 changes: 27 additions & 0 deletions models/build/edfi_3/students/bld_ef3__student_wide_address.sql
keenzarate213 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
with stg_student_address as (
select * from {{ ref('stg_ef3__stu_ed_org__addresses') }}
),
address_types as (
select * from {{ ref('xwalk_student_address_types') }}
keenzarate213 marked this conversation as resolved.
Show resolved Hide resolved
),
address_wide as (
select
k_student,
tenant_code
{%- if not is_empty_model('xwalk_student_address_types') -%},
{{ dbt_utils.pivot(
'normalized_address_type',
dbt_utils.get_column_values(ref('xwalk_student_address_types'), 'normalized_address_type'),
agg='max',
then_value='street_address',
else_value='null',
suffix='_address',
quote_identifiers = False
) }}
{%- endif %}
from stg_student_address
join address_types
on stg_student_address.address_type = address_types.original_address_type
group by k_student, tenant_code
)
select * from address_wide
27 changes: 27 additions & 0 deletions models/build/edfi_3/students/bld_ef3__student_wide_emails.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
with stg_student_emails as (
select * from {{ ref('stg_ef3__stu_ed_org__emails') }}
),
email_types as (
select * from {{ ref('xwalk_student_email_types') }}
),
emails_wide as (
select
k_student,
tenant_code
{%- if not is_empty_model('xwalk_student_email_types') -%},
{{ dbt_utils.pivot(
'normalized_email_type',
dbt_utils.get_column_values(ref('xwalk_student_email_types'), 'normalized_email_type'),
agg='max',
then_value='email_address',
else_value='null',
suffix='_email_address',
quote_identifiers = False
) }}
{%- endif %}
from stg_student_emails
join email_types
on stg_student_emails.email_type = email_types.original_email_type
group by k_student, tenant_code
)
select * from emails_wide
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
with stg_student_phones as (
select * from {{ ref('stg_ef3__stu_ed_org__telephones') }}
),
phone_number_types as (
select * from {{ ref('xwalk_student_phone_number_types') }}
),
phones_wide as (
select
k_student,
tenant_code
{%- if not is_empty_model('xwalk_student_phone_number_types') -%},
{{ dbt_utils.pivot(
'normalized_phone_number_type',
dbt_utils.get_column_values(ref('xwalk_student_phone_number_types'), 'normalized_phone_number_type'),
agg='max',
then_value='phone_number',
else_value='null',
suffix='_phone_number',
quote_identifiers = False
) }}
{%- endif %}
from stg_student_phones
join phone_number_types
on stg_student_phones.phone_number_type = phone_number_types.original_phone_number_type
group by k_student, tenant_code
)
select * from phones_wide
12 changes: 9 additions & 3 deletions models/core_warehouse/dim_student.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
{% 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) %}

{# Load customizable column name for language use, defaults as home_language #}
{% set language_use_name = var('edu:stu_language:language_use_col_name') %}

with stg_student as (
select * from {{ ref('stg_ef3__students') }}
Expand All @@ -49,7 +51,9 @@ stu_programs as (
stu_grade as (
select * from {{ ref('bld_ef3__stu_grade_level') }}
),

stu_language as (
select * from {{ ref('bld_ef3__choose_stu_language')}}
),
-- student programs
{% if var('src:program:special_ed:enabled', True) %}
stu_special_ed as (
Expand Down Expand Up @@ -188,8 +192,8 @@ formatted as (
stg_student.api_year = max(stg_student.api_year) over(partition by stg_student.k_student_xyear) as is_latest_record,

stu_immutable_demos.race_array,
stu_immutable_demos.safe_display_name

stu_immutable_demos.safe_display_name,
stu_language.code_value as {{ language_use_name }}
keenzarate213 marked this conversation as resolved.
Show resolved Hide resolved
from stg_student

join stu_demos
Expand All @@ -212,6 +216,8 @@ formatted as (
left join stu_grade
on stu_demos.k_student = stu_grade.k_student
and stg_student.api_year = stu_grade.school_year
left join stu_language
on stg_student.k_student = stu_language.k_student

-- student programs
{% if var('src:program:special_ed:enabled', True) %}
Expand Down
7 changes: 6 additions & 1 deletion models/core_warehouse/dim_subgroup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
tags=['bypass_rls']
)
}}

{# bring in the customizable column name for language use from dim_student, defaults as home_language #}
{% set language_use_name = var('edu:stu_language:language_use_col_name') %}

with dim_student as (
select * from {{ ref('dim_student') }}
),
Expand Down Expand Up @@ -32,7 +36,8 @@ stu_long_subgroup as (
'display_name',
'birth_date',
'race_array',
'safe_display_name'
'safe_display_name',
language_use_name
],
remove = stu_id_cols,
field_name='subgroup_category',
Expand Down
36 changes: 36 additions & 0 deletions models/core_warehouse/fct_student_contact_information.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
with stu_phone_wide as (
select * from {{ ref('bld_ef3__student_wide_phone_numbers') }}
),
stu_emails_wide as (
select * from {{ ref('bld_ef3__student_wide_emails') }}
),
stu_address_wide as (
select * from {{ ref('bld_ef3__student_wide_address') }}
),
dim_student as (
select * from {{ ref('dim_student') }}
)
select
dim_student.k_student,
dim_student.k_student_xyear,
dim_student.tenant_code,
dim_student.school_year,
{{ accordion_columns(
source_table='bld_ef3__student_wide_phone_numbers',
exclude_columns=["k_student", "tenant_code"],
source_alias='stu_phone_wide'
) }}
{{ accordion_columns(
source_table='bld_ef3__student_wide_emails',
exclude_columns=["k_student", "tenant_code"],
source_alias='stu_emails_wide'
) }}
{{ accordion_columns(
source_table='bld_ef3__student_wide_address',
exclude_columns=["k_student", "tenant_code"],
source_alias='stu_address_wide'
) }}
from dim_student
left join stu_phone_wide on dim_student.k_student = stu_phone_wide.k_student
left join stu_emails_wide on dim_student.k_student = stu_emails_wide.k_student
left join stu_address_wide on dim_student.k_student = stu_address_wide.k_student
6 changes: 5 additions & 1 deletion models/core_warehouse/fct_student_subgroup.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{# bring in the customizable column name for language use from dim_student, defaults as home_language #}
{% set language_use_name = var('edu:stu_language:language_use_col_name') %}

with dim_student as (
select * from {{ ref('dim_student') }}
),
Expand All @@ -24,7 +27,8 @@ stu_long_subgroup as (
'display_name',
'birth_date',
'race_array',
'safe_display_name'
'safe_display_name',
language_use_name
],
remove = stu_id_cols,
field_name='subgroup_category',
Expand Down