Skip to content

Commit a00ecfa

Browse files
committed
refactor: create a separate database for dbt
Moves dbt models into a separate database in ClickHouse for more granular permissions
1 parent 7f25f4f commit a00ecfa

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Aspects Learner Analytics combines several free, open source, tools to add analy
99
- `Vector <https://vector.dev/>`__, a log forwarding tool that can be used to forward tracking log and xAPI data to ClickHouse
1010
- `event-routing-backends <https://https://event-routing-backends.readthedocs.io/en/latest/>`__, an Open edX plugin that transforms tracking logs into xAPI and optionally forwards them to one or more Learning Record Stores in near real time
1111
- `event-sink-clickhouse <https://github.com/openedx/openedx-event-sink-clickhouse>`__, an Open edX plugin that exports course structure and high level data to ClickHouse at publish time
12+
- `dbt <https://www.getdbt.com/>`__, a tool to build data pipelines from SQL queries. The dbt project used by this plugin is `aspects-dbt <https://github.com/openedx/aspects-dbt>`__.
1213

1314
See https://github.com/openedx/openedx-oars for more details about the Aspects architecture and high level documentation.
1415

tutoraspects/plugin.py

+2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@
186186
# This is a pip compliant list of Python packages to install to run dbt
187187
# make sure packages with versions are enclosed in double quotes
188188
("EXTRA_DBT_PACKAGES", []),
189+
# This is the name of the database dbt will write to
190+
("DBT_PROFILE_TARGET_DATABASE", "reporting"),
189191
# If set, DDL/table operations will be executed with the `ON CLUSTER` clause
190192
# using this cluster. This has not been tested with Aspects and is unlikely to
191193
# work.

tutoraspects/templates/aspects/apps/aspects/dbt/profiles.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ aspects: # this needs to match the profile in your dbt_project.yml file
33
outputs:
44
dev:
55
type: clickhouse
6-
schema: {{ ASPECTS_XAPI_DATABASE }}
6+
schema: {{ DBT_PROFILE_TARGET_DATABASE }}
77
host: {{ CLICKHOUSE_HOST }}
88
port: {{ CLICKHOUSE_PORT }}
99
user: {{ CLICKHOUSE_ADMIN_USER }}

tutoraspects/templates/aspects/apps/superset/pythonpath/assets.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@
692692
warning_text: null
693693
offset: 0
694694
params: null
695-
schema: {{ ASPECTS_XAPI_DATABASE }}
695+
schema: {{ DBT_PROFILE_TARGET_DATABASE }}
696696
sql: ''
697697
table_name: video_plays
698698
template_params: null
@@ -789,7 +789,7 @@
789789
warning_text: null
790790
offset: 0
791791
params: null
792-
schema: {{ ASPECTS_XAPI_DATABASE }}
792+
schema: {{ DBT_PROFILE_TARGET_DATABASE }}
793793
sql: ''
794794
table_name: transcript_usage
795795
template_params: null

tutoraspects/templates/aspects/jobs/init/clickhouse/init-clickhouse.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ CREATE TABLE IF NOT EXISTS {{ ASPECTS_EVENT_SINK_DATABASE }}.{{ ASPECTS_EVENT_SI
335335
336336
-- Grant permissions to the users
337337
GRANT INSERT, SELECT ON {{ ASPECTS_XAPI_DATABASE }}.* TO '{{ ASPECTS_CLICKHOUSE_LRS_USER }}';
338-
GRANT SELECT, DROP TABLE, DROP VIEW ON {{ ASPECTS_XAPI_DATABASE }}.* TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}';
338+
GRANT SELECT ON {{ DBT_PROFILE_TARGET_DATABASE }}.* TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}';
339339
340340
GRANT INSERT, SELECT ON {{ ASPECTS_EVENT_SINK_DATABASE }}.* TO '{{ ASPECTS_CLICKHOUSE_CMS_USER }}';
341341
GRANT SELECT ON {{ ASPECTS_EVENT_SINK_DATABASE }}.* TO '{{ ASPECTS_CLICKHOUSE_REPORT_USER }}';

0 commit comments

Comments
 (0)