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

add configurable stu-program-agg columns #73

Merged
merged 4 commits into from
Oct 2, 2023

Conversation

rlittle08
Copy link
Collaborator

@rlittle08 rlittle08 commented Sep 8, 2023

Description and Motivation

By default in EDU, programs have is_active and is_annual as indicators that are aggregated by k_student. Those are written in build models like here. This feature branch adds the ability to add arbitrarily many more of those types of student aggregate program indicators, with custom rules.

For example, if you want to add a new indicator for whether a student was in a 504 Plan Program during the school year, you can configure these variable in your dbt_project.yml, assuming your implementation has program_name values equal to '504 Plan':

  # custom indicators in special ed model at the same agg level as is_special_ed_active & annual
  'edu:special_ed:custom_program_agg_indicators':
    is_504_plan_annual:
      agg_sql: >
        -- if the student had a 504 program enrollment any time during the year  
 
        max(
          program_name = '504 Plan'
        )

And the compiled code in the build model will look like this:

-- custom special ed program agg indicators
-- if the student had a 504 program enrollment any time during the year
max(
  program_name = '504 Plan'
)
 as is_504_plan_annual,

And any student with a program enrollment with name '504 Plan' will now have is_504_plan_annual = TRUE in dim_student. Plus, those values will be automatically added to dim_subgroup and fct_student_subgroup.

Changes to existing models:

  • bld_ef3__student_program__special_education, this code optionally adds more agg columns by grabbing sql code from the project config:
    -- custom special ed program agg indicators
    {% if custom_program_agg_indicators is not none and custom_program_agg_indicators | length -%}
    {%- for indicator in custom_program_agg_indicators -%}
    {{ custom_program_agg_indicators[indicator]['agg_sql'] }} as {{ indicator }},
    {%- endfor -%}
    {%- endif %}
    • (Same code is repeated for bld_ef3__student_program__homeless, bld_ef3__student_program__language_instruction, and bld_ef3__student_program__title_i )
  • dim_student, this code adds new custom indicators as columns:
    {% if custom_program_agg_indicators is not none and custom_program_agg_indicators | length -%}
    {% for custom_indicator in custom_program_agg_indicators %}
    coalesce(stu_special_ed.{{custom_indicator}}, false) as {{custom_indicator}},
    {% endfor %}
    • (Same code is repeated for bld_ef3__student_program__homeless, bld_ef3__student_program__language_instruction, and bld_ef3__student_program__title_i )

New models added:

None

Tests and QC Done:

Tested on Boston with configuration of 504 plan annual & active indicators.

Also tested on SCDE with configuration of homeless unaccompanied youth indicators.

Tested in both Boston and SCDE with an empty & missing config

If adding configuration, did you test with empty, broken, and nonexistent configuration?

Yes, I tested with no configuration added, and the new code compiles to empty.

PR Merge Priority:

(Promised this feature by end of Sept for BPS)

  • Low
  • Medium
  • High

Questions:

This code assumes your configuration will include SQL to aggregate over k_student. What if you want to add a k_student_xyear aggregation? Should that be included in this branch?

@rlittle08 rlittle08 marked this pull request as draft September 8, 2023 21:15
Copy link
Contributor

@jalvord1 jalvord1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we talked through this idea but noting here that I think it's a common enough use-case to account for any additional complexity, especially considering the added logic to not require the new var

@rlittle08 rlittle08 marked this pull request as ready for review September 25, 2023 17:49
-- custom homeless program agg indicators
{% if custom_program_agg_indicators is not none and custom_program_agg_indicators | length -%}
{%- for indicator in custom_program_agg_indicators -%}
{{ custom_program_agg_indicators[indicator]['agg_sql'] }} as {{ indicator }},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for nesting the SQL query under the agg_sql key? Are there other keys that we will want to add in the future for flexibility?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is possible in future we want more attributes, e.g. include_in_dim_student

@jayckaiser
Copy link
Contributor

I've left two comments regarding general structure of the changes. Overall, this addition looks good and adds much-needed flexibility when it comes to custom programs.

@ejoranlienea ejoranlienea merged commit d824d18 into main Oct 2, 2023
@ejoranlienea ejoranlienea deleted the feature/custom_program_agg_indicators branch October 2, 2023 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants