Skip to content

Bugfix/staff school association dedupe #118

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
15 changes: 13 additions & 2 deletions models/staging/edfi_3/stage/stg_ef3__staff_school_associations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@ keyed as (
from base_staff_school_assoc

),
deduped as (
-- The first dedupe step removes duplicates within api_years that occur when the optional school_year field is updated
deduped_api_year as (
{{
dbt_utils.deduplicate(
relation='keyed',
partition_by='k_staff, k_school, program_assignment, api_year',
order_by='pull_timestamp desc'
)
}}
-- The second dedupe step removes duplicates across api_years
),
deduped_school_year as (
{{
dbt_utils.deduplicate(
relation='deduped_api_year',
partition_by='k_staff, k_school, program_assignment, school_year',
order_by='pull_timestamp desc'
)
}}
)
select * from deduped
select * from deduped_school_year