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/02 08:25:34 UTC

[superset] branch 1.0 updated (39c7cc3 -> d6bd5b8)

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

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


    from 39c7cc3  update version and changelog
     new b90ac85  add order by for bar charts (#12661)
     new 3496b73  fix: bar chart data order (#12665)
     new d6bd5b8  fix: Presto column_type_mappings time and timestamp (#12861)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 superset/db_engine_specs/presto.py    |  2 +-
 superset/viz.py                       |  1 +
 tests/core_tests.py                   | 94 +++++++++++++++++++++++++++++++++++
 tests/db_engine_specs/presto_tests.py |  6 +++
 4 files changed, 102 insertions(+), 1 deletion(-)


[superset] 02/03: fix: bar chart data order (#12665)

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3496b73f8bed8f9e60a75b4da0279cd138cf53b7
Author: Karol Kostrzewa <ka...@gmail.com>
AuthorDate: Fri Jan 22 11:38:33 2021 +0100

    fix: bar chart data order (#12665)
    
    * fix bar chart order
    
    * fix test_explore_json_dist_bar_order
    
    * fix quotes
---
 superset/viz.py     |  2 +-
 tests/core_tests.py | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/superset/viz.py b/superset/viz.py
index 7d9a7bb..41abbac 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1684,7 +1684,7 @@ class DistributionBarViz(BaseViz):
             raise QueryObjectValidationError(_("Pick at least one metric"))
         if not fd.get("groupby"):
             raise QueryObjectValidationError(_("Pick at least one field for [Series]"))
-        d["orderby"] = [(d["metrics"][0], False)]
+        d["orderby"] = [(metric, False) for metric in d["metrics"]]
         return d
 
     def get_data(self, df: pd.DataFrame) -> VizData:
diff --git a/tests/core_tests.py b/tests/core_tests.py
index bcf5061..819a9c9 100644
--- a/tests/core_tests.py
+++ b/tests/core_tests.py
@@ -890,6 +890,100 @@ class TestCore(SupersetTestCase):
         self.assertEqual(data["rowcount"], 2)
 
     @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
+    def test_explore_json_dist_bar_order(self):
+        tbl_id = self.table_ids.get("birth_names")
+        form_data = {
+            "datasource": f"{tbl_id}__table",
+            "viz_type": "dist_bar",
+            "url_params": {},
+            "time_range_endpoints": ["inclusive", "exclusive"],
+            "granularity_sqla": "ds",
+            "time_range": 'DATEADD(DATETIME("2021-01-22T00:00:00"), -100, year) : 2021-01-22T00:00:00',
+            "metrics": [
+                {
+                    "expressionType": "SIMPLE",
+                    "column": {
+                        "id": 334,
+                        "column_name": "name",
+                        "verbose_name": "null",
+                        "description": "null",
+                        "expression": "",
+                        "filterable": True,
+                        "groupby": True,
+                        "is_dttm": False,
+                        "type": "VARCHAR(255)",
+                        "python_date_format": "null",
+                    },
+                    "aggregate": "COUNT",
+                    "sqlExpression": "null",
+                    "isNew": False,
+                    "hasCustomLabel": False,
+                    "label": "COUNT(name)",
+                    "optionName": "metric_xdzsijn42f9_khi4h3v3vci",
+                },
+                {
+                    "expressionType": "SIMPLE",
+                    "column": {
+                        "id": 332,
+                        "column_name": "ds",
+                        "verbose_name": "null",
+                        "description": "null",
+                        "expression": "",
+                        "filterable": True,
+                        "groupby": True,
+                        "is_dttm": True,
+                        "type": "TIMESTAMP WITHOUT TIME ZONE",
+                        "python_date_format": "null",
+                    },
+                    "aggregate": "COUNT",
+                    "sqlExpression": "null",
+                    "isNew": False,
+                    "hasCustomLabel": False,
+                    "label": "COUNT(ds)",
+                    "optionName": "metric_80g1qb9b6o7_ci5vquydcbe",
+                },
+            ],
+            "adhoc_filters": [],
+            "groupby": ["name"],
+            "columns": [],
+            "row_limit": 10,
+            "color_scheme": "supersetColors",
+            "label_colors": {},
+            "show_legend": True,
+            "y_axis_format": "SMART_NUMBER",
+            "bottom_margin": "auto",
+            "x_ticks_layout": "auto",
+        }
+
+        self.login(username="admin")
+        rv = self.client.post(
+            "/superset/explore_json/", data={"form_data": json.dumps(form_data)},
+        )
+        data = json.loads(rv.data.decode("utf-8"))
+
+        resp = self.run_sql(
+            """
+            SELECT count(name) AS count_name, count(ds) AS count_ds
+            FROM birth_names
+            WHERE ds >= '1921-01-22 00:00:00.000000' AND ds < '2021-01-22 00:00:00.000000'
+            GROUP BY name ORDER BY count_name DESC, count_ds DESC
+            LIMIT 10;
+            """,
+            client_id="client_id_1",
+            user_name="admin",
+        )
+        count_ds = []
+        count_name = []
+        for series in data["data"]:
+            if series["key"] == "COUNT(ds)":
+                count_ds = series["values"]
+            if series["key"] == "COUNT(name)":
+                count_name = series["values"]
+        for expected, actual_ds, actual_name in zip(resp["data"], count_ds, count_name):
+            assert expected["count_name"] == actual_name["y"]
+            assert expected["count_ds"] == actual_ds["y"]
+
+    @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
     @mock.patch.dict(
         "superset.extensions.feature_flag_manager._feature_flags",
         GLOBAL_ASYNC_QUERIES=True,


[superset] 01/03: add order by for bar charts (#12661)

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b90ac851adc223122ea4f27e380386bea230361d
Author: bryanck <br...@gmail.com>
AuthorDate: Thu Jan 21 23:00:58 2021 -0800

    add order by for bar charts (#12661)
    
    Co-authored-by: Bryan Keller <bk...@netflix.com>
---
 superset/viz.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/superset/viz.py b/superset/viz.py
index 37fb490..7d9a7bb 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1684,6 +1684,7 @@ class DistributionBarViz(BaseViz):
             raise QueryObjectValidationError(_("Pick at least one metric"))
         if not fd.get("groupby"):
             raise QueryObjectValidationError(_("Pick at least one field for [Series]"))
+        d["orderby"] = [(d["metrics"][0], False)]
         return d
 
     def get_data(self, df: pd.DataFrame) -> VizData:


[superset] 03/03: fix: Presto column_type_mappings time and timestamp (#12861)

Posted by vi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d6bd5b8ea24538207a640be23a8e51360914dfc3
Author: Ricardo Gândara Pinto <rp...@gmail.com>
AuthorDate: Mon Feb 1 15:41:57 2021 +0000

    fix: Presto column_type_mappings time and timestamp (#12861)
    
    * Fix presto column_type_mappings time and timestamp
    
    * Added unit tests
---
 superset/db_engine_specs/presto.py    | 2 +-
 tests/db_engine_specs/presto_tests.py | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/superset/db_engine_specs/presto.py b/superset/db_engine_specs/presto.py
index 6ef6d9d..1c1868b 100644
--- a/superset/db_engine_specs/presto.py
+++ b/superset/db_engine_specs/presto.py
@@ -353,8 +353,8 @@ class PrestoEngineSpec(BaseEngineSpec):  # pylint: disable=too-many-public-metho
         (re.compile(r"^varbinary.*", re.IGNORECASE), types.VARBINARY()),
         (re.compile(r"^json.*", re.IGNORECASE), types.JSON()),
         (re.compile(r"^date.*", re.IGNORECASE), types.DATE()),
-        (re.compile(r"^time.*", re.IGNORECASE), types.Time()),
         (re.compile(r"^timestamp.*", re.IGNORECASE), types.TIMESTAMP()),
+        (re.compile(r"^time.*", re.IGNORECASE), types.Time()),
         (re.compile(r"^interval.*", re.IGNORECASE), Interval()),
         (re.compile(r"^array.*", re.IGNORECASE), Array()),
         (re.compile(r"^map.*", re.IGNORECASE), Map()),
diff --git a/tests/db_engine_specs/presto_tests.py b/tests/db_engine_specs/presto_tests.py
index 9a493d3..721c2db 100644
--- a/tests/db_engine_specs/presto_tests.py
+++ b/tests/db_engine_specs/presto_tests.py
@@ -513,6 +513,12 @@ class TestPrestoDbEngineSpec(TestDbEngineSpec):
         sqla_type = PrestoEngineSpec.get_sqla_column_type("integer")
         assert isinstance(sqla_type, types.Integer)
 
+        sqla_type = PrestoEngineSpec.get_sqla_column_type("time")
+        assert isinstance(sqla_type, types.Time)
+
+        sqla_type = PrestoEngineSpec.get_sqla_column_type("timestamp")
+        assert isinstance(sqla_type, types.TIMESTAMP)
+
         sqla_type = PrestoEngineSpec.get_sqla_column_type(None)
         assert sqla_type is None