bito-code-review[bot] commented on code in PR #37120:
URL: https://github.com/apache/superset/pull/37120#discussion_r3653913664
##########
superset/commands/dataset/export.py:
##########
@@ -103,32 +107,41 @@ def _export(
)
file_path = f"databases/{db_file_name}.yaml"
- payload = model.database.export_to_dict(
- recursive=False,
- include_parent_ref=False,
- include_defaults=True,
- export_uuids=True,
- )
- # TODO (betodealmeida): move this logic to export_to_dict once this
- # becomes the default export endpoint
- if payload.get("extra"):
- try:
- payload["extra"] = json.loads(payload["extra"])
- except json.JSONDecodeError:
- logger.info("Unable to decode `extra` field: %s",
payload["extra"])
-
- if ssh_tunnel := model.database.ssh_tunnel:
- ssh_tunnel_payload = ssh_tunnel.export_to_dict(
+ # Only yield the database file if not already seen. This is
+ # critical to fix the issue where databases were being
+ # duplicated and potentially overwritten when charts from
+ # different databases were exported.
+ if file_path not in seen:
Review Comment:
<!-- Bito Reply -->
The reviewer's suggestion to update the `seen` set is correct. Even if the
deduplication logic is handled in the `run()` loop, updating the `seen` set
within this function ensures that the state remains consistent and prevents
redundant processing or potential issues if this function is called
independently or refactored in the future.
**superset/commands/dataset/export.py**
```
# Only yield the database file if not already seen. This is
# critical to fix the issue where databases were being
# duplicated and potentially overwritten when charts from
# different databases were exported.
if file_path not in seen:
seen.add(file_path)
yield file_path
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]