Skip to content

fix(enrollment_detail_report): fix two join fan-out bugs #2468

Merged
rachellougee merged 1 commit into
mainfrom
fix/enrollment-detail-report-course-and-discount-scd2
Jul 22, 2026
Merged

fix(enrollment_detail_report): fix two join fan-out bugs #2468
rachellougee merged 1 commit into
mainfrom
fix/enrollment-detail-report-course-and-discount-scd2

Conversation

@rachellougee

@rachellougee rachellougee commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

NA
Discovered by #2469

Description (What does it do?)

Fixes bugs in enrollment_detail_report that caused duplicate rows (fan-out) for some enrollments, leading to inconsistent values after the switch to use dimensional models

  • Course title: some enrollments show the wrong (outdated) course title instead of the course's current title.
  • Coupon: some enrollments show a coupon name that belonged to a different platform's version of the same coupon code (e.g. an MITx Online enrollment showing an xPro coupon's name).

Also exposes enrollment_key as a new output column — a reliable unique identifier for each row, to help catch and track down any remaining duplicate-row issues

Test plan

  • Verified both fixes by rebuilding the report from unchanged upstream data and confirming the previously-inconsistent values are now stable and correct
  • Confirmed coupon names now correctly match their platform

How can this be tested?

dbt build --select enrollment_detail_report - a warning due to tfact_certificate's user_fk issues that will be addressed separately

Confirmed that coupon fields produce consistent values per platform

 select platform, coupon_code, coupon_name, count(*) as n                                                                                                       
  from "ol_data_lake_production"."ol_warehouse_production_rlougee_reporting".enrollment_detail_report                                                                    
  where coupon_code = 'NEWYEAR24'                                                                                                                                
  group by platform, coupon_code, coupon_name 

confirmed that course title shows the correct name for some courses

  select courserunenrollment_id, course_readable_id, course_title, courserun_readable_id                                                                         
  from "ol_data_lake_production"."ol_warehouse_production_rlougee_reporting".enrollment_detail_report                                                                    
  where course_readable_id = 'course-v1:MITxT+FIN.CFx';    

Additional Context

Copilot AI review requested due to automatic review settings July 21, 2026 19:41
@github-actions

Copy link
Copy Markdown

🔎 ol-dbt impact — column-level blast radius

0 breaking, 0 warning, 1 info across 1 changed model(s).

Details
  • ℹ️ enrollment_detail_reportenrollment_key → 0 downstream model(s)

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

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 updates the enrollment_detail_report dbt model to eliminate two confirmed join fan-out sources that could produce duplicate rows and inconsistent attribute values after the shift to dimensional models. It also adds a stable surrogate identifier (enrollment_key) to make row-level uniqueness easier to audit downstream.

Changes:

  • Filter dim_course to is_current = true to prevent SCD2 multi-version joins from producing duplicate enrollments / outdated course titles.
  • Deduplicate and join coupon/discount names by both discount_code and platform to prevent cross-platform coupon name mismatches.
  • Expose enrollment_key in the report output and add not_null + unique (warn-severity) tests in the reporting schema YAML.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/ol_dbt/models/reporting/enrollment_detail_report.sql Prevents course-title and coupon-name fan-out by constraining joins to current course rows and platform-scoped discount names; adds enrollment_key to output.
src/ol_dbt/models/reporting/_reporting__models.yml Documents the new enrollment_key column and adds not_null + warn-severity unique tests for tracking/reporting duplicate-row issues.

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

@KatelynGit KatelynGit 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.

LGTM

@rachellougee
rachellougee merged commit fab10f0 into main Jul 22, 2026
8 checks passed
@rachellougee
rachellougee deleted the fix/enrollment-detail-report-course-and-discount-scd2 branch July 22, 2026 18:46
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.

3 participants