post https://api.sigmacomputing.com/v2/workbooks//swapSources
Swap the data sources used by a workbook. You can swap from one connection to another, and/or from one dataset to another.
Usage notes
-
Retrieve the workbookId by calling the /v2/workbooks endpoint.
-
Retrieve the connectionId by calling the /v2/connections endpoint.
-
To map the sources of a specific element, you can use the table or dataset ID:
- Retrieve the fromId for a specific data element by calling the /v2/workbooks/{workbookId}/lineage/elements/{elementId} endpoint and using the
source
key from the response, which looks likeinode-2PBoXx3UabchxF1F3l07kE
. The ID is everything afterinode-
. - Retrieve table and dataset IDs by calling the /v2/files endpoint. Use the
typeFilters
option to filter for table and dataset files. Useid
field in the response as thefromId
ortoId
, as relevant.
- Retrieve the fromId for a specific data element by calling the /v2/workbooks/{workbookId}/lineage/elements/{elementId} endpoint and using the
-
To swap all tables in a connection, set the
swapTables
option totrue
.- Use the
paths
option to specify the connection paths to swap. The connection path is a list of strings that represents the path to the table in the cloud data warehouse. For example,["database", "schema", "table"]
. - If the table schema is the same in both connections, leave the
paths
option empty to swap all tables in the connection. You can also pass a partial path to swap between databases, catalogs, or schemas. - If
sourceMapping
is provided, those mappings take precedence over the connection swaps. - If
swapTables
is not set totrue
, only Custom SQL and Input Table elements have their connections changed.
- Use the
Usage scenarios
- Workbook development: Use a test data source while developing a workbook, then swap the source to the a production database when ready to share the workbook for production use.