From 8c7c21bd542aa5f68c56169e6cb352fc6349c3da Mon Sep 17 00:00:00 2001 From: Mayur Singal <39544459+ulixius9@users.noreply.github.com> Date: Mon, 30 Jan 2023 20:10:52 +0530 Subject: [PATCH] Fix Superset Owners & Descriptions (#10007) --- .../source/dashboard/superset/api_source.py | 2 +- .../source/dashboard/superset/db_source.py | 2 +- .../source/dashboard/superset/mixin.py | 19 ++++++++++++++++--- .../source/dashboard/superset/queries.py | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ingestion/src/metadata/ingestion/source/dashboard/superset/api_source.py b/ingestion/src/metadata/ingestion/source/dashboard/superset/api_source.py index 370426f5a64..0b1f69548e7 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/superset/api_source.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/superset/api_source.py @@ -143,7 +143,7 @@ class SupersetAPISource(SupersetSourceMixin): chart = CreateChartRequest( name=chart_json["id"], displayName=chart_json.get("slice_name"), - description="", + description=chart_json.get("description"), chartType=get_standard_chart_type( chart_json.get("viz_type", ChartType.Other.value) ), diff --git a/ingestion/src/metadata/ingestion/source/dashboard/superset/db_source.py b/ingestion/src/metadata/ingestion/source/dashboard/superset/db_source.py index 85b4fe6db5f..242dacdeda0 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/superset/db_source.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/superset/db_source.py @@ -147,7 +147,7 @@ class SupersetDBSource(SupersetSourceMixin): chart = CreateChartRequest( name=chart_json["id"], displayName=chart_json.get("slice_name"), - description="", + description=chart_json.get("description"), chartType=get_standard_chart_type( chart_json.get("viz_type", ChartType.Other.value) ), diff --git a/ingestion/src/metadata/ingestion/source/dashboard/superset/mixin.py b/ingestion/src/metadata/ingestion/source/dashboard/superset/mixin.py index f0aaf722f81..ede1abb95bb 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/superset/mixin.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/superset/mixin.py @@ -69,11 +69,24 @@ class SupersetSourceMixin(DashboardServiceSource): """ return dashboard - def get_owner_details(self, dashboard_details: dict) -> EntityReference: - if dashboard_details.get("email"): - user = self.metadata.get_user_by_email(dashboard_details["email"]) + def _get_user_by_email(self, email: str) -> EntityReference: + + if email: + user = self.metadata.get_user_by_email(email) if user: return EntityReference(id=user.id.__root__, type="user") + + return None + + def get_owner_details(self, dashboard_details: dict) -> EntityReference: + for owner in dashboard_details.get("owners", []): + user = self._get_user_by_email(owner["email"]) + if user: + return user + if dashboard_details.get("email"): + user = self._get_user_by_email(dashboard_details["email"]) + if user: + return user return None def _get_charts_of_dashboard(self, dashboard_details: dict) -> List[str]: diff --git a/ingestion/src/metadata/ingestion/source/dashboard/superset/queries.py b/ingestion/src/metadata/ingestion/source/dashboard/superset/queries.py index 1f675993065..ec4fd248184 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/superset/queries.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/superset/queries.py @@ -16,6 +16,7 @@ FETCH_ALL_CHARTS = """ select s.id, s.slice_name, + s.description, t.table_name, t.schema, db.database_name,