feat(#2075): add courserun_upgrade_deadline to dim_course_run and enrollment_is_edx_enrolled to tfact_enrollment#2317
Merged
Conversation
…ollment_is_edx_enrolled to tfact_enrollment - dim_course_run: add courserun_upgrade_deadline (MITxOnline from source; null for all other platforms) Propagated through combined_courseruns_resolved, final SELECT, and records_to_expire SCD2 block - tfact_enrollment: add enrollment_is_edx_enrolled (edxorg/residential=true, mitxonline/mitxpro from source field, program/bootcamps=null) Propagated through final, final_deduped, and final SELECT These fields are prerequisites for migrating marts__combined_course_enrollment_detail to the dimensional layer (tracked in a follow-up PR). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
quazi-h
added a commit
that referenced
this pull request
Jun 17, 2026
These changes are now in a separate prerequisite PR: #2317 This branch now contains only the mart rewrite. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds two missing attributes to dimensional-layer dbt models to support the upcoming migration of marts__combined_course_enrollment_detail to dimensional sources (issue #2075 / prerequisite for PR #2314).
Changes:
- Add
enrollment_is_edx_enrolledtotfact_enrollment, populated from MITxOnline/MITxPro sources and hardcoded per platform where appropriate. - Add
courserun_upgrade_deadlinetodim_course_run, populated for MITxOnline and null for other platforms, and propagated through the SCD2 flow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/ol_dbt/models/dimensional/tfact_enrollment.sql |
Adds enrollment_is_edx_enrolled across platform CTEs and propagates it to the final fact output. |
src/ol_dbt/models/dimensional/dim_course_run.sql |
Adds courserun_upgrade_deadline to the dimensional SCD2 model output and expiry block. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… docs - Add courserun_upgrade_deadline to the incremental change-detection predicate (not exists block) so that a deadline change alone triggers a new SCD2 version. Previously, a change in upgrade_deadline with no other field changes would be silently ignored. - Add YAML column definition for courserun_upgrade_deadline in _dim_course_run.yml - Add YAML column definitions for enrollment_is_edx_enrolled and enrollment_updated_on in _fact_tables.yml Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ia micromasters join edxorg course run sources do not carry upgrade_deadline natively. The value is stored in the MicroMasters course run table keyed by courserun_edxorg_readable_id. Added micromasters_courseruns CTE and left-joined it to edxorg_courseruns so downstream marts (e.g. marts__combined_course_enrollment_detail) get parity with the existing combined enrollment detail output, which sources this field from int__edxorg__mitx_courserun_enrollments via the same micromasters join. Validated: 365 of 1,515 edxorg course runs now have upgrade_deadline populated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…te column docs
Add WHERE courserun_platform = '{{ var("edxorg") }}' to the micromasters_courseruns
CTE to prevent cross-platform false matches and 1:N fan-out if multiple MicroMasters
rows share the same courserun_edxorg_readable_id.
Update courserun_upgrade_deadline column description to reflect that edxorg runs
are also populated (via MicroMasters join), not just MITxOnline.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…org fan-out Add QUALIFY ROW_NUMBER() OVER (PARTITION BY courserun_edxorg_readable_id ORDER BY courserun_id DESC) = 1 to the micromasters_courseruns CTE. courserun_id is an auto-increment PK so DESC picks the most recently inserted row per readable ID, preventing 1:N fan-out if multiple edxorg MicroMasters rows share the same courserun_edxorg_readable_id. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…no compatibility Trino does not support the QUALIFY clause. Replace the micromasters_courseruns dedup with the equivalent ROW_NUMBER() inner-subquery pattern, consistent with the existing pattern documented and used in dim_course.sql. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Trino requires all subqueries in FROM clauses to have an alias. The derived table used for ROW_NUMBER dedup was missing 'as mcr_deduped', which would cause a parse error at runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ginal formatting Reconstructs dim_course_run.sql to preserve the file's original leading-comma formatting instead of the full-file trailing-comma rewrite introduced earlier in this PR. Only the actual logical additions from this PR are retained: - new micromasters_courseruns CTE (deduped, edxorg-platform-filtered lookup for courserun_upgrade_deadline) - courserun_upgrade_deadline threaded through each per-platform CTE, the SCD2 change-detection predicate, and records_to_expire Verified equivalent to the prior version via token-level diff (only quote-style differences remain), dbt parse/compile against a local duckdb target, and sqlfluff-lint/-fix (no changes needed). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolves conflicts in dim_course_run.sql and _dim_course_run.yml between this PR's courserun_upgrade_deadline addition (#2075) and #2319's semester/passing_grade addition, which merged to main first. Both sets of changes are additive and independent (different CTEs, different platform sourcing), so the resolution keeps both: - micromasters_courseruns CTE (courserun_upgrade_deadline, edxorg-keyed) - micromasters_examruns CTE (semester/passing_grade, mitxonline-keyed) - Both columns threaded through mitxonline_courseruns, all other per-platform CTEs, the SCD2 change-detection predicate, final SELECT, and records_to_expire - Both column docs retained in _dim_course_run.yml Verified with dbt compile --select dim_course_run tfact_enrollment (clean) and sqlfluff-lint/-fix (no changes needed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
Closes #2075 (partial — prerequisite for mart migration PR #2314)
Description (What does it do?)
Adds two missing fields to existing dimensional models. These are prerequisite changes that must be deployed (with
--full-refresh) before the mart migration in #2314 is deployed.dim_course_run.sql— addcourserun_upgrade_deadlineint__mitxonline__course_runs.courserun_upgrade_deadline(field already exists in that int model)courserun_edxorg_readable_id), which carry an upgrade deadline for the associated edxorg course runcast(null as varchar)— upgrade deadlines only exist on MITxOnline and edX.org (MicroMasters exam runs)combined_courseruns_resolved,finalSELECT, andrecords_to_expireSCD2 expiry blockcourserun_upgrade_deadlineadded to the SCD2 change-detection predicate so deadline changes alone trigger a new SCD2 versiontfact_enrollment.sql— addenrollment_is_edx_enrolledcourserunenrollment_is_edx_enrolledfromint__mitxonline__courserunenrollmentscourserunenrollment_is_edx_enrolledfromint__mitxpro__courserunenrollmentstrue(all edxorg enrollments are on an edX-hosted platform)true(MIT Residential is OpenEdX-based)cast(null as boolean)(program-level concept, not course-run-level)cast(null as boolean)(Bootcamps is not edX-hosted)final,final_deduped, and final SELECTHow can this be tested?
After deploying to QA with
--full-refresh:Additional Context
Deployment note —
--full-refreshrequired:Both models are incremental (
delete+insert). Adding a new column withon_schema_change='append_new_columns'will ALTER the table and add the column, but existing rows will have NULL for the new column until those rows are reprocessed by an incremental run.Since most rows won't be reprocessed (course runs and enrollments don't change often), the columns will remain mostly NULL for historical data unless the models are run with
--full-refresh.Recommended deploy order:
int__bootcamps__course_runs --full-refresh(picks up recently-addedcourse_readable_idcolumn)int__bootcamps__courserunenrollments --full-refresh(picks up recently-addedcourserunenrollment_updated_oncolumn)dim_course_run --full-refreshtfact_enrollment --full-refreshSteps 1–2 are needed because these bootcamps intermediate tables were materialized before their respective column additions were merged to main. Steps 3–4 depend on those columns being present.
This two-phase approach ensures the mart migration has fully-populated dimensional columns on deploy, with no regression window.