You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2023/08/28 16:47:26 UTC
[superset] branch master updated: fix(assets import): Ensure old datasource ids are not referenced in imported charts (#25086)
This is an automated email from the ASF dual-hosted git repository.
elizabeth 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 b240b795b5 fix(assets import): Ensure old datasource ids are not referenced in imported charts (#25086)
b240b795b5 is described below
commit b240b795b5bae4e9f7bd6b5e4ff73e771c76d8dd
Author: Jack Fragassi <jf...@gmail.com>
AuthorDate: Mon Aug 28 09:47:19 2023 -0700
fix(assets import): Ensure old datasource ids are not referenced in imported charts (#25086)
---
superset/commands/importers/v1/assets.py | 9 ++++++++-
tests/integration_tests/commands_test.py | 3 +++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/superset/commands/importers/v1/assets.py b/superset/commands/importers/v1/assets.py
index 1ab2e486cf..f0720d70b1 100644
--- a/superset/commands/importers/v1/assets.py
+++ b/superset/commands/importers/v1/assets.py
@@ -79,6 +79,7 @@ class ImportAssetsCommand(BaseCommand):
)
self._configs: dict[str, Any] = {}
+ # pylint: disable=too-many-locals
@staticmethod
def _import(session: Session, configs: dict[str, Any]) -> None:
# import databases first
@@ -110,7 +111,13 @@ class ImportAssetsCommand(BaseCommand):
chart_ids: dict[str, int] = {}
for file_name, config in configs.items():
if file_name.startswith("charts/"):
- 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=True)
chart_ids[str(chart.uuid)] = chart.id
diff --git a/tests/integration_tests/commands_test.py b/tests/integration_tests/commands_test.py
index 86ebdc0951..6512a141be 100644
--- a/tests/integration_tests/commands_test.py
+++ b/tests/integration_tests/commands_test.py
@@ -141,6 +141,9 @@ class TestImportAssetsCommand(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"]