Skip to content

Commit

Permalink
Add actionable error for country map vis
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed Apr 9, 2021
1 parent 1805732 commit 0e6ddb4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1951,8 +1951,16 @@ class CountryMapViz(BaseViz):

def query_obj(self) -> QueryObjectDict:
qry = super().query_obj()
qry["metrics"] = [self.form_data["metric"]]
qry["groupby"] = [self.form_data["entity"]]
metric = self.form_data.get("metric")
entity = self.form_data.get("entity")
if not self.form_data.get("select_country"):
raise QueryObjectValidationError("Must specify a country")
if not metric:
raise QueryObjectValidationError("Must specify a metric")
if not entity:
raise QueryObjectValidationError("Must provide ISO codes")
qry["metrics"] = [metric]
qry["groupby"] = [entity]
return qry

def get_data(self, df: pd.DataFrame) -> VizData:
Expand Down

0 comments on commit 0e6ddb4

Please sign in to comment.