Skip to content

Commit

Permalink
fix: sorting by saved metric
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Feb 10, 2021
1 parent 3e0681b commit b4fc2d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,8 @@ def get_sqla_query( # pylint: disable=too-many-arguments,too-many-locals,too-ma
col = self.adhoc_metric_to_sqla(col, columns_by_name)
elif col in columns_by_name:
col = columns_by_name[col].get_sqla_col()
elif col in metrics_by_name:
col = metrics_by_name[col].get_sqla_col()

if isinstance(col, Label):
label = col._label # pylint: disable=protected-access
Expand Down
7 changes: 4 additions & 3 deletions superset/examples/birth_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ def create_slices(
groupby=["name"],
adhoc_filters=[gen_filter("gender", "girl")],
row_limit=50,
timeseries_limit_metric="sum__num",
metrics=metrics,
timeseries_limit_metric=metric,
metrics=[metric],
),
),
Slice(
Expand Down Expand Up @@ -300,7 +300,8 @@ def create_slices(
groupby=["name"],
adhoc_filters=[gen_filter("gender", "boy")],
row_limit=50,
metrics=metrics,
timeseries_limit_metric=metric,
metrics=[metric],
),
),
Slice(
Expand Down

0 comments on commit b4fc2d6

Please sign in to comment.