You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2023/04/05 20:38:50 UTC
[superset] branch master updated: fix(dash import): Ensure old datasource ids are not referenced in imported charts (#23582)
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 70344018b6 fix(dash import): Ensure old datasource ids are not referenced in imported charts (#23582)
70344018b6 is described below
commit 70344018b67dba8072d6c26a3b24fdc7354d9681
Author: Jack Fragassi <jf...@gmail.com>
AuthorDate: Wed Apr 5 13:38:41 2023 -0700
fix(dash import): Ensure old datasource ids are not referenced in imported charts (#23582)
---
superset/dashboards/commands/importers/v1/__init__.py | 9 ++++++++-
tests/integration_tests/dashboards/commands_tests.py | 3 +++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/superset/dashboards/commands/importers/v1/__init__.py b/superset/dashboards/commands/importers/v1/__init__.py
index 83d26fc7e7..5d83a580bd 100644
--- a/superset/dashboards/commands/importers/v1/__init__.py
+++ b/superset/dashboards/commands/importers/v1/__init__.py
@@ -112,7 +112,14 @@ class ImportDashboardsCommand(ImportModelsCommand):
and config["dataset_uuid"] in dataset_info
):
# update datasource id, type, and name
- config.update(dataset_info[config["dataset_uuid"]])
+ dataset_dict = dataset_info[config["dataset_uuid"]]
+ config.update(dataset_dict)
+ # pylint: disable=line-too-long
+ dataset_uid = f"{dataset_dict['datasource_id']}__{dataset_dict['datasource_type']}"
+ config["params"].update({"datasource": dataset_uid})
+ if "query_context" in config:
+ del config["query_context"]
+
chart = import_chart(session, config, overwrite=False)
chart_ids[str(chart.uuid)] = chart.id
diff --git a/tests/integration_tests/dashboards/commands_tests.py b/tests/integration_tests/dashboards/commands_tests.py
index 6fe2b92aae..ad9152585e 100644
--- a/tests/integration_tests/dashboards/commands_tests.py
+++ b/tests/integration_tests/dashboards/commands_tests.py
@@ -565,6 +565,9 @@ class TestImportDashboardsCommand(SupersetTestCase):
dataset = chart.table
assert str(dataset.uuid) == dataset_config["uuid"]
+ assert chart.query_context is None
+ assert json.loads(chart.params)["datasource"] == dataset.uid
+
database = dataset.database
assert str(database.uuid) == database_config["uuid"]