From commits-return-3953-archive-asf-public=cust-asf.ponee.io@superset.incubator.apache.org Tue Mar 17 17:47:19 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id B3B2718057A for ; Tue, 17 Mar 2020 18:47:18 +0100 (CET) Received: (qmail 10726 invoked by uid 500); 17 Mar 2020 17:47:18 -0000 Mailing-List: contact commits-help@superset.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@superset.incubator.apache.org Delivered-To: mailing list commits@superset.incubator.apache.org Received: (qmail 10716 invoked by uid 99); 17 Mar 2020 17:47:18 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Mar 2020 17:47:18 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B21708DACA; Tue, 17 Mar 2020 17:47:17 +0000 (UTC) Date: Tue, 17 Mar 2020 17:47:16 +0000 To: "commits@superset.apache.org" Subject: [incubator-superset] branch master updated: fix: big number to handle NULL as it did in the past (#9314) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <158446723612.9974.7994999252565157752@gitbox.apache.org> From: maximebeauchemin@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-superset X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 85e9a4fa990927327755f5743317e848fc230f01 X-Git-Newrev: 6cf36c91ea95b501491cbc828709172cf29b21cf X-Git-Rev: 6cf36c91ea95b501491cbc828709172cf29b21cf X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. maximebeauchemin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git The following commit(s) were added to refs/heads/master by this push: new 6cf36c9 fix: big number to handle NULL as it did in the past (#9314) 6cf36c9 is described below commit 6cf36c91ea95b501491cbc828709172cf29b21cf Author: Maxime Beauchemin AuthorDate: Tue Mar 17 10:46:59 2020 -0700 fix: big number to handle NULL as it did in the past (#9314) --- superset/viz.py | 4 ++-- tests/viz_tests.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/superset/viz.py b/superset/viz.py index 433fede..13bde2a 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -1126,8 +1126,8 @@ class BigNumberViz(BaseViz): index=DTTM_ALIAS, columns=[], values=self.metric_labels, - fill_value=0, - aggfunc=sum, + dropna=False, + aggfunc=np.min, # looking for any (only) value, preserving `None` ) df = self.apply_rolling(df) df[DTTM_ALIAS] = df.index diff --git a/tests/viz_tests.py b/tests/viz_tests.py index ec318e6..80da72e 100644 --- a/tests/viz_tests.py +++ b/tests/viz_tests.py @@ -1243,3 +1243,31 @@ class TimeSeriesVizTestCase(SupersetTestCase): .tolist(), [1.0, 1.5, 2.0, 2.5], ) + + +class BigNumberVizTestCase(SupersetTestCase): + def test_get_data(self): + datasource = self.get_datasource_mock() + df = pd.DataFrame( + data={ + DTTM_ALIAS: pd.to_datetime( + ["2019-01-01", "2019-01-02", "2019-01-05", "2019-01-07"] + ), + "y": [1.0, 2.0, 3.0, 4.0], + } + ) + data = viz.BigNumberViz(datasource, {"metrics": ["y"]}).get_data(df) + self.assertEqual(data[2], {DTTM_ALIAS: pd.Timestamp("2019-01-05"), "y": 3}) + + def test_get_data_with_none(self): + datasource = self.get_datasource_mock() + df = pd.DataFrame( + data={ + DTTM_ALIAS: pd.to_datetime( + ["2019-01-01", "2019-01-02", "2019-01-05", "2019-01-07"] + ), + "y": [1.0, 2.0, None, 4.0], + } + ) + data = viz.BigNumberViz(datasource, {"metrics": ["y"]}).get_data(df) + assert np.isnan(data[2]["y"])