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 2021/02/10 19:46:18 UTC

[superset] branch master updated: fix: sorting by saved metric (#13059)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c1e10c4  fix: sorting by saved metric (#13059)
c1e10c4 is described below

commit c1e10c4627f91871dd4c72f8a662c200d5d4b3e9
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Wed Feb 10 21:45:45 2021 +0200

    fix: sorting by saved metric (#13059)
---
 superset/connectors/sqla/models.py | 2 ++
 superset/examples/birth_names.py   | 7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/superset/connectors/sqla/models.py b/superset/connectors/sqla/models.py
index b7204fe..a64a628 100644
--- a/superset/connectors/sqla/models.py
+++ b/superset/connectors/sqla/models.py
@@ -1150,6 +1150,8 @@ class SqlaTable(  # pylint: disable=too-many-public-methods,too-many-instance-at
                 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
diff --git a/superset/examples/birth_names.py b/superset/examples/birth_names.py
index a872994..583a099 100644
--- a/superset/examples/birth_names.py
+++ b/superset/examples/birth_names.py
@@ -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(
@@ -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(