How can we programmatically Replace one Analysis’ Dataset to Another Dataset?

How can we programmatically Replace one Analysis’ Dataset to Another Dataset

2 Likes

Hi,

Not as you requested but you can get idea from QS cross account migration.

Regards,
Naveed Ali

2 Likes

Hi @Palak_Shah - are you going to copy the analysis to another analysis and update the data source in the second in the same account? If yes, then one of the solution is create the template and create the analysis with update the data set ids of the template. It is part of the solution link provided by @Naveed .

Regards - Sanjeeb

1 Like

I also look for a solution here.

I have tried several options with CLI to avoid the middle step of using templates.
The reason for this is that I would like to replace a dataset in ALL the analyses it’s being used. If I create a template, and a new analysis from that template, I will also have to migrate ownership, shared folders, etc.

Update Analysis from CLI requires either that you have a template defined in SourceEntity, or that you have a Definition.

  1. DON’T update-analysis with only DatasetIdentifierDeclarations.
    This will remove all your sheets and leave the analysis broken and non-recoverable.

  2. Download the Definition using describe-analysis-definition, and then update-analysis with the same or updated definition. I have tried this using both JSON and YAML, and I only get ‘Invalid JSON/YAML receieved’ from VS Code.
    I’ve tried removing the elements that doesn’t belong there like “Status”, "ResourceStatus, “RequestId”.
    If someone knows how I can get more details on what is incorrect , that would be of great help.

  3. Download Definition and create-analysis. This still seems to give me the same ‘Invalid JSON/YAML received’ error. Also, creating from scratch is not a viable option, as I would still have to update permissions, folder memberships.

  4. Overwrite the existing data set, using update-data-set. This is also not a good option.
    a) It will probably break some analyses since in my case I’m changing from a SPICE data set built on top of other SPICE data sets to a SPICE dataset on an Athena query.
    b) It will also enforce ALL analyses to use this new data set. In other cases you might just want to update some of your analyses.

  5. As Admin, take ownership of all analyses/dashboards, replace the dataset manually and sacve/publish. We all agree that this is not a good option.

Let me know if anyone have better options for me

1 Like