Skip to content

Commit

Permalink
feat: partition all tables by year and month
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Jan 26, 2024
1 parent 051ca59 commit 2a409d3
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions models/base/xapi_events_all_parsed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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)',
partition_by='(toYYYYMM(emission_time))',
post_hook='OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL'
) }}

Expand Down
1 change: 1 addition & 0 deletions models/completion/completion_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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)'
partition_by='(toYYYYMM(emission_time))',
) }}

SELECT
Expand Down
1 change: 1 addition & 0 deletions models/enrollment/enrollment_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key)',
order_by='(org, course_key, emission_time, actor_id, enrollment_mode, event_id)'
partition_by='(toYYYYMM(emission_time))',
) }}

SELECT
Expand Down
1 change: 1 addition & 0 deletions models/forum/forum_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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)'
partition_by='(toYYYYMM(emission_time))',
) }}

SELECT
Expand Down
3 changes: 2 additions & 1 deletion models/grading/grading_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
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)'
order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, scaled_score, event_id)'}
partition_by='(toYYYYMM(emission_time))',
) }}


Expand Down
1 change: 1 addition & 0 deletions models/navigation/navigation_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
engine=get_engine('ReplacingMergeTree()'),
primary_key='(org, course_key, object_type)',
order_by='(org, course_key, object_type, emission_time, actor_id, starting_position, event_id)'
partition_by='(toYYYYMM(emission_time))',
) }}

SELECT
Expand Down
1 change: 1 addition & 0 deletions models/problems/problem_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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)'
partition_by='(toYYYYMM(emission_time))',
) }}

SELECT
Expand Down
1 change: 1 addition & 0 deletions models/video/video_playback_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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)'
partition_by='(toYYYYMM(emission_time))',
) }}

SELECT
Expand Down
1 change: 1 addition & 0 deletions models/video/video_transcript_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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)'
partition_by='(toYYYYMM(emission_time))',
) }}

SELECT
Expand Down

0 comments on commit 2a409d3

Please sign in to comment.