diff --git a/superset/viz.py b/superset/viz.py index 0ed3e306b..cc5a89a7e 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -1133,6 +1133,9 @@ class BigNumberViz(BaseViz): return d def get_data(self, df: pd.DataFrame) -> VizData: + if df.empty: + return None + df = df.pivot_table( index=DTTM_ALIAS, columns=[], @@ -1868,6 +1871,9 @@ class WorldMapViz(BaseViz): return qry def get_data(self, df: pd.DataFrame) -> VizData: + if df.empty: + return None + from superset.examples import countries fd = self.form_data @@ -1942,7 +1948,7 @@ class FilterBoxViz(BaseViz): col = flt.get("column") metric = flt.get("metric") df = self.dataframes.get(col) - if df is not None: + if df is not None and not df.empty: if metric: df = df.sort_values( utils.get_metric_name(metric), ascending=flt.get("asc") @@ -1957,6 +1963,8 @@ class FilterBoxViz(BaseViz): {"id": row[0], "text": row[0]} for row in df.itertuples(index=False) ] + else: + df[col] = [] return d