You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by er...@apache.org on 2021/05/04 22:35:36 UTC
[superset] branch master updated: fix: dashboard datasources filter
None (#14471)
This is an automated email from the ASF dual-hosted git repository.
erikrit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new a816655 fix: dashboard datasources filter None (#14471)
a816655 is described below
commit a81665571597dd9943610529bf471d5face4e26f
Author: Erik Ritter <er...@airbnb.com>
AuthorDate: Tue May 4 15:34:38 2021 -0700
fix: dashboard datasources filter None (#14471)
---
superset/models/dashboard.py | 2 +-
superset/models/slice.py | 7 ++++---
superset/views/core.py | 7 +++++++
superset/views/utils.py | 4 ++--
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/superset/models/dashboard.py b/superset/models/dashboard.py
index 6f1e6bf..6203cb4 100644
--- a/superset/models/dashboard.py
+++ b/superset/models/dashboard.py
@@ -171,7 +171,7 @@ class Dashboard( # pylint: disable=too-many-instance-attributes
@property
def datasources(self) -> Set[BaseDatasource]:
- return {slc.datasource for slc in self.slices}
+ return {slc.datasource for slc in self.slices if slc.datasource}
@property
def charts(self) -> List[BaseDatasource]:
diff --git a/superset/models/slice.py b/superset/models/slice.py
index 9efd07d..c80e1fb 100644
--- a/superset/models/slice.py
+++ b/superset/models/slice.py
@@ -100,7 +100,7 @@ class Slice(
return ConnectorRegistry.sources[self.datasource_type]
@property
- def datasource(self) -> "BaseDatasource":
+ def datasource(self) -> Optional["BaseDatasource"]:
return self.get_datasource
def clone(self) -> "Slice":
@@ -160,8 +160,9 @@ class Slice(
def viz(self) -> Optional[BaseViz]:
form_data = json.loads(self.params)
viz_class = viz_types.get(self.viz_type)
- if viz_class:
- return viz_class(datasource=self.datasource, form_data=form_data)
+ datasource = self.datasource
+ if viz_class and datasource:
+ return viz_class(datasource=datasource, form_data=form_data)
return None
@property
diff --git a/superset/views/core.py b/superset/views/core.py
index e9cdff1..aff0990 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -462,6 +462,10 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
form_data, slc = get_form_data(slice_id, use_slice_data=True)
if not slc:
return json_error_response("The slice does not exist")
+
+ if not slc.datasource:
+ return json_error_response("The slice's datasource does not exist")
+
try:
viz_obj = get_viz(
datasource_type=slc.datasource.type,
@@ -1709,6 +1713,9 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
else get_dashboard_extra_filters(slc.id, dashboard_id)
)
+ if not slc.datasource:
+ raise Exception("Slice's datasource does not exist")
+
obj = get_viz(
datasource_type=slc.datasource.type,
datasource_id=slc.datasource.id,
diff --git a/superset/views/utils.py b/superset/views/utils.py
index 9c4ec73..b0fea97 100644
--- a/superset/views/utils.py
+++ b/superset/views/utils.py
@@ -290,7 +290,7 @@ def get_time_range_endpoints(
if not slc:
slc = db.session.query(Slice).filter_by(id=slice_id).one_or_none()
- if slc:
+ if slc and slc.datasource:
endpoints = slc.datasource.database.get_extra().get(
"time_range_endpoints"
)
@@ -533,7 +533,7 @@ def check_slice_perms(_self: Any, slice_id: int) -> None:
form_data, slc = get_form_data(slice_id, use_slice_data=True)
- if slc:
+ if slc and slc.datasource:
try:
viz_obj = get_viz(
datasource_type=slc.datasource.type,