Skip to content

Commit

Permalink
fix: write MVs to xapi schema
Browse files Browse the repository at this point in the history
This change overrides the destination database for the materialized
views that were once written to the `xapi` schema so that they can be
written to the correct database again.
  • Loading branch information
SoryRawyer committed Jan 11, 2024
1 parent edc97a2 commit feaa196
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions macros/get_custom_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro generate_schema_name(custom_schema_name, node) -%}
{{ generate_schema_name_for_env(custom_schema_name, node) }}
{%- endmacro %}
2 changes: 1 addition & 1 deletion models/base/sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2

sources:
- name: xapi
database: "{{ env_var('XAPI_SCHEMA', 'xapi') }}"
database: "{{ env_var('ASPECTS_XAPI_DATABASE', 'xapi') }}"
description: "the xapi database in clickhouse"
tables:
- name: xapi_events_all
Expand Down
1 change: 1 addition & 0 deletions models/base/xapi_events_all_parsed.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ config(
materialized='materialized_view',
schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_id, verb_id, actor_id, emission_time, event_id)',
order_by='(org, course_id, verb_id, actor_id, emission_time, event_id)',
Expand Down
1 change: 1 addition & 0 deletions models/completion/completion_events.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ config(
materialized='materialized_view',
schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key, verb_id)',
order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)'
Expand Down
1 change: 1 addition & 0 deletions models/enrollment/enrollment_events.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ config(
materialized='materialized_view',
schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key)',
order_by='(org, course_key, emission_time, actor_id, enrollment_mode, event_id)'
Expand Down
1 change: 1 addition & 0 deletions models/forum/forum_events.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ config(
materialized='materialized_view',
schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key, verb_id)',
order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)'
Expand Down
1 change: 1 addition & 0 deletions models/grading/grading_events.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ config(
materialized='materialized_view',
schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key, verb_id)',
order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, scaled_score, event_id)'
Expand Down
1 change: 1 addition & 0 deletions models/problems/problem_events.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ config(
materialized='materialized_view',
schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key, verb_id)',
order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, responses, success, event_id)'
Expand Down
1 change: 1 addition & 0 deletions models/video/video_playback_events.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ config(
materialized='materialized_view',
schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key, verb_id)',
order_by='(org, course_key, verb_id, emission_time, actor_id, video_position, event_id)'
Expand Down
1 change: 1 addition & 0 deletions models/video/video_transcript_events.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ config(
materialized='materialized_view',
schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key, video_id)',
order_by='(org, course_key, video_id, emission_time, actor_id, cc_enabled, event_id)'
Expand Down
4 changes: 2 additions & 2 deletions sample_profiles.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
aspects: # this needs to match the profile in your dbt_project.yml file
target: dev
target: prod
outputs:
dev:
prod:
type: clickhouse
schema: xapi
host: localhost
Expand Down

0 comments on commit feaa196

Please sign in to comment.