Fix #6862: Improve Superset dict handling (#6864)

This commit is contained in:
Mayur Singal 2022-08-23 13:37:09 +05:30 committed by GitHub
parent 3d125d9372
commit f32572c949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@ from typing import Iterable, List, Optional
from metadata.generated.schema.api.data.createChart import CreateChartRequest
from metadata.generated.schema.api.data.createDashboard import CreateDashboardRequest
from metadata.generated.schema.api.lineage.addLineage import AddLineageRequest
from metadata.generated.schema.entity.data.chart import ChartType
from metadata.generated.schema.entity.data.dashboard import (
Dashboard as Lineage_Dashboard,
)
@ -178,9 +179,9 @@ class SupersetSource(DashboardServiceSource):
if raw_position_data:
position_data = json.loads(raw_position_data)
return [
value.get("meta", {}).get("chartId", "unknown")
value.get("meta", {}).get("chartId")
for key, value in position_data.items()
if key.startswith("CHART-")
if key.startswith("CHART-") and value.get("meta", {}).get("chartId")
]
return []
@ -241,18 +242,17 @@ class SupersetSource(DashboardServiceSource):
"""
for chart_id in self._get_charts_of_dashboard(dashboard_details):
chart_json = self.all_charts.get(chart_id)
chart_id = chart_json["id"]
params = json.loads(chart_json["params"])
group_bys = params.get("groupby", []) or []
if isinstance(group_bys, str):
group_bys = [group_bys]
if not chart_json:
logger.warning(f"chart details for id: {chart_id} not found, skipped")
continue
chart = CreateChartRequest(
name=chart_id,
displayName=chart_json["slice_name"],
name=chart_json["id"],
displayName=chart_json.get("slice_name"),
description="",
chartType=get_standard_chart_type(chart_json["viz_type"]),
chartUrl=chart_json["url"],
chartType=get_standard_chart_type(
chart_json.get("viz_type", ChartType.Other.value)
),
chartUrl=chart_json.get("url"),
service=EntityReference(
id=self.context.dashboard_service.id.__root__,
type="dashboardService",