withnale opened a new issue, #31443:
URL: https://github.com/apache/superset/issues/31443

   ### Bug description
   
   **The example below is discussing the use case for `/api/v1/assets/import` 
but similar logic appears in the `Import*Command` method for 
dataset/chart/dashboard specific APIs and methods...**
   
   When trying to use `/api/v1/assets/import/` to import a dashboard, it forces 
all resources to be imported. 
   
   If we look at the implementation, it reads something like this. Within each 
'startwith' block in maintains a dict
   of all the updated resources, and in the subsequent block it uses this as a 
lookup (only the code in the datasets block 
   is shown)
   
   ```python
           # import databases first
           database_ids: dict[str, int] = {}
           for file_name, config in configs.items():
               if file_name.startswith("databases/"):
                   ... 
           # import saved queries
           for file_name, config in configs.items():
               if file_name.startswith("queries/"):
                   ...
   
           # import datasets
           dataset_info: dict[str, dict[str, Any]] = {}
           for file_name, config in configs.items():
               if file_name.startswith("datasets/"):
                   config["database_id"] = database_ids[config["database_uuid"]]
                   dataset = import_dataset(config, overwrite=True)
                   dataset_info[str(dataset.uuid)] = {
                       "datasource_id": dataset.id,
                       "datasource_type": dataset.datasource_type,
                       "datasource_name": dataset.table_name,
                   }
               
           # import charts
           charts = []
           chart_ids: dict[str, int] = {}
           for file_name, config in configs.items():
               if file_name.startswith("charts/"):
                   dataset_dict = dataset_info[config["dataset_uuid"]]
                   ...
   
           # import dashboards
           for file_name, config in configs.items():
               if file_name.startswith("dashboards/"):
                   ...
   ```
   
   Unfortunately this means that any dashboard update must also include the 
chart, dataset, query and database.
   
   Whilst I can understand the reasoning for this to ensure there is no drift 
when exporting and importing, this does
   cause problems propagating changes through different superset instances. It 
also causes problems in multi-tenant
   environments where we want to maintain different update policies for 
charts/dashboard to datasets/databases.
   
   An alternative that might seem possible is to introduce a new parameter to 
the import process similar to overwrite - for arguments sake, lets call it 
`sparse`. If this is set to true, if it cannot find the dependency uuid 
referenced in the zip bundle, it will look it up and use it from the running 
database.
   
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [X] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [X] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [X] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
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: notifications-unsubscr...@superset.apache.org.apache.org

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


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

Reply via email to