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 ab8af53 Fixing the examples (#7376)
ab8af53 is described below
commit ab8af536b011bcc6dfb68f053816a6385fbef043
Author: Maxime Beauchemin <[email protected]>
AuthorDate: Thu Jul 4 13:23:02 2019 -0700
Fixing the examples (#7376)
Fixing a few failing examples, examples were referencing metrics that
were getting auto-generated in the past (like `sum__num`),
that we now prevent from getting created.
---
superset/assets/src/explore/controlPanels/DeckPolygon.js | 2 +-
superset/assets/src/explore/controls.jsx | 1 +
superset/data/birth_names.py | 16 ++++++++++------
superset/data/unicode_test_data.py | 7 +++----
superset/data/world_bank.py | 13 +++++++++++--
superset/viz.py | 2 +-
tests/core_tests.py | 3 ++-
7 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/superset/assets/src/explore/controlPanels/DeckPolygon.js
b/superset/assets/src/explore/controlPanels/DeckPolygon.js
index d038c54..2579021 100644
--- a/superset/assets/src/explore/controlPanels/DeckPolygon.js
+++ b/superset/assets/src/explore/controlPanels/DeckPolygon.js
@@ -26,10 +26,10 @@ export default {
label: t('Query'),
expanded: true,
controlSetRows: [
+ ['line_column', 'line_type'],
['adhoc_filters'],
['metric', 'point_radius_fixed'],
['row_limit', null],
- ['line_column', 'line_type'],
['reverse_long_lat', 'filter_nulls'],
],
},
diff --git a/superset/assets/src/explore/controls.jsx
b/superset/assets/src/explore/controls.jsx
index 6f3578b..f03925c 100644
--- a/superset/assets/src/explore/controls.jsx
+++ b/superset/assets/src/explore/controls.jsx
@@ -171,6 +171,7 @@ const metric = {
...metrics,
multi: false,
label: t('Metric'),
+ description: t('Metric'),
default: props => mainMetric(props.savedMetrics),
};
diff --git a/superset/data/birth_names.py b/superset/data/birth_names.py
index 112082b..9040847 100644
--- a/superset/data/birth_names.py
+++ b/superset/data/birth_names.py
@@ -91,7 +91,15 @@ def load_birth_names():
"granularity_sqla": "ds",
"groupby": [],
"metric": "sum__num",
- "metrics": ["sum__num"],
+ "metrics": [
+ {
+ "expressionType": "SIMPLE",
+ "column": {"column_name": "num", "type": "BIGINT"},
+ "aggregate": "SUM",
+ "label": "Births",
+ "optionName": "metric_11",
+ }
+ ],
"row_limit": config.get("ROW_LIMIT"),
"since": "100 years ago",
"until": "now",
@@ -261,11 +269,7 @@ def load_birth_names():
datasource_type="table",
datasource_id=tbl.id,
params=get_slice_json(
- defaults,
- viz_type="pivot_table",
- metrics=["sum__num"],
- groupby=["name"],
- columns=["state"],
+ defaults, viz_type="pivot_table", groupby=["name"],
columns=["state"]
),
),
Slice(
diff --git a/superset/data/unicode_test_data.py
b/superset/data/unicode_test_data.py
index 943bfc3..3f3ed55 100644
--- a/superset/data/unicode_test_data.py
+++ b/superset/data/unicode_test_data.py
@@ -76,11 +76,10 @@ def load_unicode_test_data():
"granularity_sqla": "dttm",
"groupby": [],
"metric": {
- "expressionType": "SIMPLE",
- "column": {"column_name": "value", "type": "INT"},
"aggregate": "SUM",
- "label": "value",
- "optionName": "metric_11",
+ "column": {"column_name": "value"},
+ "expressionType": "SIMPLE",
+ "label": "Value",
},
"row_limit": config.get("ROW_LIMIT"),
"since": "100 years ago",
diff --git a/superset/data/world_bank.py b/superset/data/world_bank.py
index f00269b..a64bd2b 100644
--- a/superset/data/world_bank.py
+++ b/superset/data/world_bank.py
@@ -106,7 +106,17 @@ def load_world_bank_health_n_pop():
"where": "",
"markup_type": "markdown",
"country_fieldtype": "cca3",
- "secondary_metric": "sum__SP_POP_TOTL",
+ "secondary_metric": {
+ "aggregate": "SUM",
+ "column": {
+ "column_name": "SP_RUR_TOTL",
+ "optionName": "_col_SP_RUR_TOTL",
+ "type": "DOUBLE",
+ },
+ "expressionType": "SIMPLE",
+ "hasCustomLabel": True,
+ "label": "Rural Population",
+ },
"entity": "country_code",
"show_bubbles": True,
}
@@ -244,7 +254,6 @@ def load_world_bank_health_n_pop():
defaults,
viz_type="sunburst",
groupby=["region", "country_name"],
- secondary_metric="sum__SP_RUR_TOTL",
since="2011-01-01",
until="2011-01-01",
),
diff --git a/superset/viz.py b/superset/viz.py
index 7ffd753..f802787 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -683,7 +683,7 @@ class PivotTableViz(BaseViz):
if self.form_data.get("granularity") == "all" and DTTM_ALIAS in df:
del df[DTTM_ALIAS]
- aggfunc = self.form_data.get("pandas_aggfunc")
+ aggfunc = self.form_data.get("pandas_aggfunc") or "sum"
# Ensure that Pandas's sum function mimics that of SQL.
if aggfunc == "sum":
diff --git a/tests/core_tests.py b/tests/core_tests.py
index 2fdd6ad..ea3b889 100644
--- a/tests/core_tests.py
+++ b/tests/core_tests.py
@@ -280,7 +280,8 @@ class CoreTests(SupersetTestCase):
]
for name, method, url in urls:
logging.info(f"[{name}]/[{method}]: {url}")
- self.client.get(url)
+ resp = self.client.get(url)
+ self.assertEqual(resp.status_code, 200)
def test_tablemodelview_list(self):
self.login(username="admin")