diff --git a/tutoraspects/templates/openedx-assets/queries/fact_enrollment_pii.sql b/tutoraspects/templates/openedx-assets/queries/fact_enrollment_pii.sql index dad31e38c..a55fce5e6 100644 --- a/tutoraspects/templates/openedx-assets/queries/fact_enrollment_pii.sql +++ b/tutoraspects/templates/openedx-assets/queries/fact_enrollment_pii.sql @@ -26,5 +26,8 @@ select from enrollments inner join {{ DBT_PROFILE_TARGET_DATABASE }}.dim_user_pii as users - on (enrollments.actor_id like 'mailto:%' and SUBSTRING(enrollments.actor_id, 8) = users.email) + on ( + enrollments.actor_id like 'mailto:%' + and SUBSTRING(enrollments.actor_id, 8) = users.email + ) or enrollments.actor_id = toString(users.external_user_id) diff --git a/tutoraspects/templates/openedx-assets/queries/int_problem_results.sql b/tutoraspects/templates/openedx-assets/queries/int_problem_results.sql index 16f813056..ff5737a4a 100644 --- a/tutoraspects/templates/openedx-assets/queries/int_problem_results.sql +++ b/tutoraspects/templates/openedx-assets/queries/int_problem_results.sql @@ -87,7 +87,10 @@ join ) left outer join {{ ASPECTS_EVENT_SINK_DATABASE }}.user_pii users - on (full_responses.actor_id like 'mailto:%' and SUBSTRING(full_responses.actor_id, 8) = users.email) + on ( + full_responses.actor_id like 'mailto:%' + and SUBSTRING(full_responses.actor_id, 8) = users.email + ) or full_responses.actor_id = toString(users.external_user_id) where 1 = 1 {% include 'openedx-assets/queries/common_filters.sql' %} diff --git a/tutoraspects/templates/openedx-assets/queries/problem_coursewide_avg.sql b/tutoraspects/templates/openedx-assets/queries/problem_coursewide_avg.sql index 8edf19a32..151735f93 100644 --- a/tutoraspects/templates/openedx-assets/queries/problem_coursewide_avg.sql +++ b/tutoraspects/templates/openedx-assets/queries/problem_coursewide_avg.sql @@ -121,7 +121,10 @@ join ) left outer join {{ ASPECTS_EVENT_SINK_DATABASE }}.user_pii users - on (full_responses.actor_id like 'mailto:%' and SUBSTRING(full_responses.actor_id, 8) = users.email) + on ( + full_responses.actor_id like 'mailto:%' + and SUBSTRING(full_responses.actor_id, 8) = users.email + ) or full_responses.actor_id = toString(users.external_user_id) join coursewide_attempts