Skip to content

Commit

Permalink
add coursesinprogram mart (#1296)
Browse files Browse the repository at this point in the history
add marts__combined__coursesinprogram as a reference table
  • Loading branch information
KatelynGit committed Sep 19, 2024
1 parent 2dd05d4 commit bb6befd
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/ol_dbt/models/marts/combined/_marts__combined__models.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
---
version: 2

models:
- name: marts__combined_coursesinprogram
description: Mart model for course to program association for the different platforms
columns:
- name: platform
description: str, name of the platform
tests:
- not_null
- name: course_readable_id
description: str, Open edX ID formatted as course-v1:{org}+{course code} e.g.
course-v1:xPRO+MLx2
- name: course_title
description: str, title of the course
- name: program_title
description: str, title of the program
- name: program_id
description: int, foreign key representing a single program
tests:
- not_null
- name: course_readable_id
description: str, Open edX ID formatted as course-v1:{org}+{course code} e.g.
course-v1:xPRO+MLx2
- name: program_readable_id
description: str, readable ID from xpro or mitxonline formatted as program-v1:{org}+{program
code} e.g.program-v1:xPRO+MLx
tests:
- dbt_expectations.expect_compound_columns_to_be_unique:
column_list: ["platform", "program_id", "course_readable_id"]

- name: marts__combined__users
description: Mart model for users from different platforms
columns:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
with mitx_programs as (
select * from {{ ref('int__mitx__program_requirements') }}
)

, mitx__courses as (
select * from {{ ref('int__mitx__courses') }}
)

, mitxpro__courses as (
select * from {{ ref('int__mitxpro__courses') }}
)

, mitxpro__programs as (
select * from {{ ref('int__mitxpro__programs') }}
)

, mitxonline__programs as (
select * from {{ ref('int__mitxonline__programs') }}
)

select
'MITx Online' as platform
, mitx__courses.course_title
, mitx_programs.program_title
, mitx_programs.mitxonline_program_id as program_id
, mitx__courses.course_readable_id
, mitxonline__programs.program_readable_id
from mitx_programs
inner join mitx__courses
on mitx_programs.course_number = mitx__courses.course_number
left join mitxonline__programs
on mitx_programs.mitxonline_program_id = mitxonline__programs.program_id
where mitx__courses.is_on_mitxonline = true

union all

select
'edX.org' as platform
, mitx__courses.course_title
, mitx_programs.program_title
, mitx_programs.micromasters_program_id as program_id
, mitx__courses.course_readable_id
, null as program_readable_id
from mitx_programs
inner join mitx__courses
on mitx_programs.course_number = mitx__courses.course_number
where mitx__courses.is_on_mitxonline = false

union all

select
'xPro' as platform
, mitxpro__courses.course_title
, mitxpro__programs.program_title
, mitxpro__courses.program_id
, mitxpro__courses.course_readable_id
, mitxpro__programs.program_readable_id
from mitxpro__courses
inner join mitxpro__programs
on mitxpro__courses.program_id = mitxpro__programs.program_id

0 comments on commit bb6befd

Please sign in to comment.