Skip to content

feat(tfact_enrollment): add Emeritus/Global Alumni platform support#2406

Open
quazi-h wants to merge 3 commits into
mainfrom
copilot/2405-emeritus-global-alumni-tfact-enrollment
Open

feat(tfact_enrollment): add Emeritus/Global Alumni platform support#2406
quazi-h wants to merge 3 commits into
mainfrom
copilot/2405-emeritus-global-alumni-tfact-enrollment

Conversation

@quazi-h

@quazi-h quazi-h commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

Closes #2405
Blocks #2075 (PR #2314 — migrate marts__combined_course_enrollment_detail to the dimensional layer)

Description (What does it do?)

Adds emeritus and global_alumni platform support to tfact_enrollment, which previously had no coverage for these two platforms. Without this, migrating marts__combined_course_enrollment_detail to source exclusively from tfact_enrollment (PR #2314) would silently drop all Emeritus/Global Alumni enrollment rows — this was flagged during Copilot review on that PR.

Changes:

  • Add emeritus_enrollments/global_alumni_enrollments CTEs sourced from stg__emeritus__api__bigquery__user_enrollments / stg__global_alumni__api__bigquery__user_enrollments — the same staging models dim_user already uses for its existing emeritus_user_id/global_alumni_user_id columns — following the existing per-platform CTE pattern in tfact_enrollment.
  • Add mitxpro_external_readable_id_lookup CTE (from int__mitxpro__course_runs) to resolve these platforms' course run FK: Emeritus/Global Alumni don't own course run records, so their enrollments map onto existing MITxPro course runs via courserun_external_readable_id, mirroring the join logic previously used in int__combined__courserun_enrollments.
  • Extend user_lookup to select emeritus_user_id/global_alumni_user_id from dim_user and thread through the user_fk coalesce chain.
  • Add dim_course_run_mitxpro CTE + join to resolve courserun_fk for these two platforms against MITxPro-platform dim_course_run rows.
  • enrollment_is_edx_enrolled = null for both (same treatment as program/bootcamps enrollments).

How can this be tested?

Additional Context

⚠️ Requires a --full-refresh of tfact_enrollment after deploy. tfact_enrollment uses incremental_strategy='delete+insert' — these new CTEs alone only capture new activity going forward. A full refresh is needed to backfill the existing historical Emeritus/Global Alumni enrollment rows before #2314 can rely on complete data.

This PR should merge and be deployed (with --full-refresh) before PR #2314 merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the dimensional enrollment fact model (tfact_enrollment) to include Emeritus and Global Alumni enrollments, so downstream consumers (notably the upcoming migration of marts__combined_course_enrollment_detail) don’t lose those platform rows when switching to dimensional sourcing.

Changes:

  • Adds Emeritus and Global Alumni enrollment CTEs and unions them into combined_enrollments.
  • Introduces a MITxPro external-readable-id lookup and a MITxPro-only dim_course_run join path to resolve courserun_fk for these platforms.
  • Extends user_lookup and FK resolution logic to support Emeritus/Global Alumni user IDs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ol_dbt/models/dimensional/tfact_enrollment.sql
Comment thread src/ol_dbt/models/dimensional/tfact_enrollment.sql Outdated
Comment thread src/ol_dbt/models/dimensional/tfact_enrollment.sql

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/ol_dbt/models/dimensional/tfact_enrollment.sql Outdated
quazi-h and others added 3 commits July 16, 2026 09:58
- Add emeritus_enrollments/global_alumni_enrollments CTEs sourced from
  stg__emeritus__api__bigquery__user_enrollments /
  stg__global_alumni__api__bigquery__user_enrollments (the same staging
  models dim_user already uses for its emeritus_user_id/global_alumni_user_id
  columns), following the existing per-platform CTE pattern.
- Add mitxpro_external_readable_id_lookup CTE (sourced from
  int__mitxpro__course_runs) to resolve these platforms' course run FK:
  Emeritus/Global Alumni don't own course run records, so their enrollments
  map onto existing MITxPro course runs via courserun_external_readable_id,
  mirroring the join logic previously used in
  int__combined__courserun_enrollments.
- Extend user_lookup to select emeritus_user_id/global_alumni_user_id from
  dim_user (already present there) and thread through the user_fk coalesce
  chain.
- Add dim_course_run_mitxpro CTE + join to resolve courserun_fk for these
  two platforms against MITxPro-platform dim_course_run rows.
- enrollment_is_edx_enrolled is null for both (same treatment as
  program/bootcamps enrollments).

Prerequisite for #2075/PR #2314 (migrate marts__combined_course_enrollment_detail
to the dimensional layer): without this, sourcing that mart exclusively from
tfact_enrollment would silently drop all Emeritus/Global Alumni enrollment rows.

Closes #2405

Requires a --full-refresh of tfact_enrollment after deploy to backfill
historical Emeritus/Global Alumni enrollment rows (incremental_strategy is
delete+insert, so new CTEs alone only capture new activity going forward).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…lobal Alumni column mapping

- Use internal platform code 'mitxpro' instead of var("mitxpro") (display label
  "xPro") when filtering dim_course_run_mitxpro, which was leaving courserun_fk
  NULL for all Emeritus/Global Alumni enrollments.
- global_alumni_enrollments: source has no enrollment_created_on column (would
  fail compilation against real data); null it out and surface the enrollment_status
  the staging model does provide instead of dropping it.
- emeritus_enrollments: source provides enrollment_updated_on; use it instead of
  NULL so incremental per-platform watermark logic works instead of falling back
  to the 7-day lookback path.
…behavior

The comment claimed Global Alumni rows fall back to the 7-day lookback path,
but that path requires enrollment_created_on to be non-null. Since Global
Alumni has neither enrollment_created_on nor enrollment_updated_on, it
actually hits the unconditional 'or ewf.enrollment_created_on is null'
branch and is fully reprocessed on every incremental run.
@blarghmatey
blarghmatey force-pushed the copilot/2405-emeritus-global-alumni-tfact-enrollment branch from 04f71c6 to 438018c Compare July 16, 2026 14:06
@github-actions

Copy link
Copy Markdown

🔎 ol-dbt impact — column-level blast radius

✅ No column-level downstream impact detected for the changed models.

Posted by ol-dbt impact (annotate-only — does not block merge).

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.

Add Emeritus/Global Alumni platform support to tfact_enrollment

2 participants