You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2020/09/05 19:36:15 UTC

[incubator-superset] 17/26: fix: dedup groupby in viz.py while preserving order (#10633)

This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch 0.37
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit a037a4718306da3432386873f6b013c25b1667da
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Thu Aug 20 22:02:02 2020 -0700

    fix: dedup groupby in viz.py while preserving order (#10633)
---
 setup.cfg                    | 2 +-
 superset/tasks/slack_util.py | 5 ++---
 superset/viz.py              | 5 +++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/setup.cfg b/setup.cfg
index c126a4a..e8505c9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -38,7 +38,7 @@ combine_as_imports = true
 include_trailing_comma = true
 line_length = 88
 known_first_party = superset
-known_third_party =alembic,apispec,backoff,bleach,cachelib,celery,click,colorama,contextlib2,croniter,cryptography,dataclasses,dateutil,flask,flask_appbuilder,flask_babel,flask_caching,flask_compress,flask_login,flask_migrate,flask_sqlalchemy,flask_talisman,flask_testing,flask_wtf,geohash,geopy,humanize,isodate,jinja2,markdown,markupsafe,marshmallow,msgpack,numpy,pandas,parameterized,parsedatetime,pathlib2,polyline,prison,pyarrow,pyhive,pytest,pytz,retry,selenium,setuptools,simplejson,sl [...]
+known_third_party =alembic,apispec,backoff,bleach,cachelib,celery,click,colorama,contextlib2,croniter,cryptography,dateutil,flask,flask_appbuilder,flask_babel,flask_caching,flask_compress,flask_login,flask_migrate,flask_sqlalchemy,flask_talisman,flask_testing,flask_wtf,geohash,geopy,humanize,isodate,jinja2,markdown,markupsafe,marshmallow,msgpack,numpy,pandas,parameterized,parsedatetime,pathlib2,polyline,prison,pyarrow,pyhive,pytest,pytz,retry,selenium,setuptools,simplejson,slack,sphinx_r [...]
 multi_line_output = 3
 order_by_type = false
 
diff --git a/superset/tasks/slack_util.py b/superset/tasks/slack_util.py
index ef647eb..08dcb16 100644
--- a/superset/tasks/slack_util.py
+++ b/superset/tasks/slack_util.py
@@ -18,15 +18,13 @@ import logging
 from io import IOBase
 from typing import cast, Union
 
+from flask import current_app
 from retry.api import retry
 from slack import WebClient
 from slack.errors import SlackApiError
 from slack.web.slack_response import SlackResponse
 
-from superset import app
-
 # Globals
-config = app.config  # type: ignore
 logger = logging.getLogger("tasks.slack_util")
 
 
@@ -34,6 +32,7 @@ logger = logging.getLogger("tasks.slack_util")
 def deliver_slack_msg(
     slack_channel: str, subject: str, body: str, file: Union[str, IOBase]
 ) -> None:
+    config = current_app.config
     client = WebClient(token=config["SLACK_API_TOKEN"], proxy=config["SLACK_PROXY"])
     # files_upload returns SlackResponse as we run it in sync mode.
     response = cast(
diff --git a/superset/viz.py b/superset/viz.py
index becdc4a..508d8aa 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -21,6 +21,7 @@ These objects represent the backend of all the visualizations that
 Superset can render.
 """
 import copy
+import dataclasses
 import inspect
 import logging
 import math
@@ -42,7 +43,6 @@ from typing import (
     Union,
 )
 
-import dataclasses
 import geohash
 import numpy as np
 import pandas as pd
@@ -322,7 +322,8 @@ class BaseViz:
         gb = self.groupby
         metrics = self.all_metrics or []
         columns = form_data.get("columns") or []
-        groupby = list(set(gb + columns))
+        # merge list and dedup while preserving order
+        groupby = list(OrderedDict.fromkeys(gb + columns))
 
         is_timeseries = self.is_timeseries
         if DTTM_ALIAS in groupby: