Unverified Commit 64b2db0f by Hassan Committed by GitHub

Merge pull request #503 from edx/hassan/fix-user-location

Fix warehouse loading tasks.
parents 16780bdb 6f0ca841
...@@ -16,7 +16,7 @@ log = logging.getLogger(__name__) ...@@ -16,7 +16,7 @@ log = logging.getLogger(__name__)
class LoadInternalReportingCountryTableHive(LastCountryOfUserDownstreamMixin, HiveTableFromQueryTask): class LoadInternalReportingCountryTableHive(LastCountryOfUserDownstreamMixin, HiveTableFromQueryTask):
"""Loads internal_reporting_d_country Hive table from last_country_of_user Hive table.""" """Loads internal_reporting_d_country Hive table from last_country_of_user_id Hive table."""
def requires(self): def requires(self):
return LastCountryOfUserPartitionTask( return LastCountryOfUserPartitionTask(
...@@ -53,7 +53,7 @@ class LoadInternalReportingCountryTableHive(LastCountryOfUserDownstreamMixin, Hi ...@@ -53,7 +53,7 @@ class LoadInternalReportingCountryTableHive(LastCountryOfUserDownstreamMixin, Hi
SELECT SELECT
collect_set(lcu.country_name)[0] collect_set(lcu.country_name)[0]
, lcu.country_code as user_last_location_country_code , lcu.country_code as user_last_location_country_code
FROM last_country_of_user lcu FROM last_country_of_user_id lcu
GROUP BY lcu.country_code GROUP BY lcu.country_code
""" """
......
...@@ -18,7 +18,7 @@ class AggregateInternalReportingUserTableHive(HiveTableFromQueryTask): ...@@ -18,7 +18,7 @@ class AggregateInternalReportingUserTableHive(HiveTableFromQueryTask):
def requires(self): def requires(self):
""" """
This task reads from auth_user, auth_user_profile, and last_country_of_user, so require that they be This task reads from auth_user, auth_user_profile, and last_country_of_user_id, so require that they be
loaded into Hive (via MySQL loads into Hive or via the pipeline as needed). loaded into Hive (via MySQL loads into Hive or via the pipeline as needed).
""" """
return [ImportAuthUserTask(overwrite=self.overwrite, destination=self.warehouse_path), return [ImportAuthUserTask(overwrite=self.overwrite, destination=self.warehouse_path),
...@@ -60,7 +60,7 @@ class AggregateInternalReportingUserTableHive(HiveTableFromQueryTask): ...@@ -60,7 +60,7 @@ class AggregateInternalReportingUserTableHive(HiveTableFromQueryTask):
, COALESCE(lc.country_code, 'UNKNOWN') , COALESCE(lc.country_code, 'UNKNOWN')
FROM auth_user au FROM auth_user au
JOIN auth_userprofile aup ON au.id = aup.user_id JOIN auth_userprofile aup ON au.id = aup.user_id
LEFT OUTER JOIN last_country_of_user lc ON au.username = lc.username LEFT OUTER JOIN last_country_of_user_id lc ON au.id = lc.user_id
SORT BY au.username ASC SORT BY au.username ASC
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment