-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: dedup groupby in viz.py while preserving order #10633
Conversation
@@ -37,6 +35,7 @@ def deliver_slack_msg( | |||
body: str, | |||
file: Optional[Union[str, IOBase, bytes]], | |||
) -> None: | |||
config = current_app.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bycatch, the mypy commit hook was triggering on this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, non-blocking nit
@@ -322,7 +322,8 @@ def query_obj(self) -> QueryObjectDict: | |||
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, as of 3.7 key order is now officially guaranteed (already implicitly so in 3.6), so no need to use OrderedDict
any more:
groupby = list(OrderedDict.fromkeys(gb + columns)) | |
groupby = list(dict.fromkeys(gb + columns)) |
Reference: https://docs.python.org/3.7/tutorial/datastructures.html#dictionaries
Performing
list(d)
on a dictionary returns a list of all the keys used in the dictionary, in insertion order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right, I remember reading about how ordering is guaranteed in py3.
Merging this for upcoming |
* master: (43 commits) feat: Getting fancier with Storybook (apache#10647) fix: dedup groupby in viz.py while preserving order (apache#10633) feat: bump superset-ui for certified tag (apache#10650) feat: setup react page with submenu for datasources listview (apache#10642) feat: add certification to metrics (apache#10630) feat(viz-plugins): add date formatting to pivot-table (apache#10637) fix: controls scroll issue (apache#10644) feat: Allow tests files in /src (plus Label component tests) (apache#10634) fix: remove duplicated params and cache_timeout from list_columns; add viz_type to list_columns (apache#10643) chore: splitting button stories into separate stories (apache#10631) refactor: remove slice level label_colors from dashboard init load (apache#10603) feat: card view bulk select (apache#10607) style: Label styling/storybook touchups (apache#10627) fix: removing unsupported modal sizes (apache#10625) feat(datasource): remove deleted columns and update column type on metadata refresh (apache#10619) improve documentation for country maps (apache#10621) chore: npm audit fix as of 2020-08-15 (apache#10613) feat: dataset REST API for distinct values (apache#10595) chore: bump react-redux to 5.1.2, whittling console noise (apache#10602) fixing console error about bad html attribute (apache#10604) ... # Conflicts: # superset-frontend/src/explore/components/ExploreViewContainer.jsx # superset-frontend/src/views/App.tsx # superset/config.py
closes #10218