mirror of https://github.com/apache/superset.git
fix: import metrics with extra (#15047)
* fix: import metrics with extra * Fix test
This commit is contained in:
parent
3f527c7a45
commit
42cb5266fa
|
@ -98,11 +98,12 @@ def import_dataset(
|
|||
except TypeError:
|
||||
logger.info("Unable to encode `%s` field: %s", key, config[key])
|
||||
for metric in config.get("metrics", []):
|
||||
if metric.get("extra"):
|
||||
if metric.get("extra") is not None:
|
||||
try:
|
||||
metric["extra"] = json.dumps(metric["extra"])
|
||||
except TypeError:
|
||||
logger.info("Unable to encode `extra` field: %s", metric["extra"])
|
||||
metric["extra"] = None
|
||||
|
||||
# should we delete columns and metrics not present in the current import?
|
||||
sync = ["columns", "metrics"] if overwrite else []
|
||||
|
|
|
@ -328,7 +328,7 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
|||
assert metric.expression == "count(1)"
|
||||
assert metric.description is None
|
||||
assert metric.d3format is None
|
||||
assert metric.extra is None
|
||||
assert metric.extra == "{}"
|
||||
assert metric.warning_text is None
|
||||
|
||||
assert len(dataset.columns) == 1
|
||||
|
|
|
@ -384,7 +384,7 @@ dataset_config: Dict[str, Any] = {
|
|||
"expression": "count(1)",
|
||||
"description": None,
|
||||
"d3format": None,
|
||||
"extra": None,
|
||||
"extra": {},
|
||||
"warning_text": None,
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue