You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/12/02 18:21:06 UTC

[GitHub] [incubator-superset] eschutho commented on a change in pull request #11786: chore: add unit tests for the current import functionality

eschutho commented on a change in pull request #11786:
URL: https://github.com/apache/incubator-superset/pull/11786#discussion_r534384377



##########
File path: superset/datasets/commands/importers/v0.py
##########
@@ -301,9 +302,23 @@ def __init__(
     def run(self) -> None:
         self.validate()
 
+        # TODO (betodealmeida): add rollback in case of error
         for file_name, config in self._configs.items():
             logger.info("Importing dataset from file %s", file_name)
-            import_from_dict(db.session, config, sync=self.sync)
+            if isinstance(config, dict):
+                import_from_dict(db.session, config, sync=self.sync)
+            else:  # list
+                for dataset in config:
+                    # UI exports don't have the database metadata, so we assume
+                    # the DB exists and has the same name
+                    params = json.loads(dataset["params"])
+                    database = (
+                        db.session.query(Database)
+                        .filter_by(database_name=params["database_name"])
+                        .one()
+                    )
+                    dataset["database_id"] = database.id

Review comment:
       do you want a guard on this if database is null?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org