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.
This commit is contained in:
Maxime Beauchemin 2019-07-04 13:23:02 -07:00 committed by GitHub
parent 39f83b5490
commit ab8af536b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 15 deletions

View File

@ -26,10 +26,10 @@ export default {
label: t('Query'), label: t('Query'),
expanded: true, expanded: true,
controlSetRows: [ controlSetRows: [
['line_column', 'line_type'],
['adhoc_filters'], ['adhoc_filters'],
['metric', 'point_radius_fixed'], ['metric', 'point_radius_fixed'],
['row_limit', null], ['row_limit', null],
['line_column', 'line_type'],
['reverse_long_lat', 'filter_nulls'], ['reverse_long_lat', 'filter_nulls'],
], ],
}, },

View File

@ -171,6 +171,7 @@ const metric = {
...metrics, ...metrics,
multi: false, multi: false,
label: t('Metric'), label: t('Metric'),
description: t('Metric'),
default: props => mainMetric(props.savedMetrics), default: props => mainMetric(props.savedMetrics),
}; };

View File

@ -91,7 +91,15 @@ def load_birth_names():
"granularity_sqla": "ds", "granularity_sqla": "ds",
"groupby": [], "groupby": [],
"metric": "sum__num", "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"), "row_limit": config.get("ROW_LIMIT"),
"since": "100 years ago", "since": "100 years ago",
"until": "now", "until": "now",
@ -261,11 +269,7 @@ def load_birth_names():
datasource_type="table", datasource_type="table",
datasource_id=tbl.id, datasource_id=tbl.id,
params=get_slice_json( params=get_slice_json(
defaults, defaults, viz_type="pivot_table", groupby=["name"], columns=["state"]
viz_type="pivot_table",
metrics=["sum__num"],
groupby=["name"],
columns=["state"],
), ),
), ),
Slice( Slice(

View File

@ -76,11 +76,10 @@ def load_unicode_test_data():
"granularity_sqla": "dttm", "granularity_sqla": "dttm",
"groupby": [], "groupby": [],
"metric": { "metric": {
"expressionType": "SIMPLE",
"column": {"column_name": "value", "type": "INT"},
"aggregate": "SUM", "aggregate": "SUM",
"label": "value", "column": {"column_name": "value"},
"optionName": "metric_11", "expressionType": "SIMPLE",
"label": "Value",
}, },
"row_limit": config.get("ROW_LIMIT"), "row_limit": config.get("ROW_LIMIT"),
"since": "100 years ago", "since": "100 years ago",

View File

@ -106,7 +106,17 @@ def load_world_bank_health_n_pop():
"where": "", "where": "",
"markup_type": "markdown", "markup_type": "markdown",
"country_fieldtype": "cca3", "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", "entity": "country_code",
"show_bubbles": True, "show_bubbles": True,
} }
@ -244,7 +254,6 @@ def load_world_bank_health_n_pop():
defaults, defaults,
viz_type="sunburst", viz_type="sunburst",
groupby=["region", "country_name"], groupby=["region", "country_name"],
secondary_metric="sum__SP_RUR_TOTL",
since="2011-01-01", since="2011-01-01",
until="2011-01-01", until="2011-01-01",
), ),

View File

@ -683,7 +683,7 @@ class PivotTableViz(BaseViz):
if self.form_data.get("granularity") == "all" and DTTM_ALIAS in df: if self.form_data.get("granularity") == "all" and DTTM_ALIAS in df:
del df[DTTM_ALIAS] 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. # Ensure that Pandas's sum function mimics that of SQL.
if aggfunc == "sum": if aggfunc == "sum":

View File

@ -280,7 +280,8 @@ class CoreTests(SupersetTestCase):
] ]
for name, method, url in urls: for name, method, url in urls:
logging.info(f"[{name}]/[{method}]: {url}") 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): def test_tablemodelview_list(self):
self.login(username="admin") self.login(username="admin")