Saving dataset with a stored procedure. #30048
Replies: 1 comment 6 replies
-
To save a dataset in Superset that includes a stored procedure execution, follow these steps:
Here is a relevant code snippet that shows how the SQL query is handled during the dataset creation process: const handleSaveInDataset = () => {
setLoading(true);
const selectedColumns = datasource?.columns ?? [];
let templateParams;
if (isString(datasource?.templateParams)) {
const p = JSON.parse(datasource.templateParams);
if (p._filters) {
delete p._filters;
templateParams = JSON.stringify(p);
}
}
dispatch(
createDatasource({
sql: datasource.sql,
dbId: datasource.dbId || datasource?.database?.id,
catalog: datasource?.catalog,
schema: datasource?.schema,
templateParams,
datasourceName: datasetName,
}),
)
.then((data: { id: number }) =>
postFormData(data.id, 'table', {
...formDataWithDefaults,
datasource: `${data.id}__table`,
...(defaultVizType === 'table' && {
all_columns: selectedColumns.map(column => column.column_name),
}),
}),
)
.then((key: string) => {
setLoading(false);
const url = mountExploreUrl(null, {
[URL_PARAMS.formDataKey.name]: key,
});
createWindow(url);
setDatasetName(getDefaultDatasetName());
onHide();
})
.catch(() => {
setLoading(false);
addDangerToast(t('An error occurred saving dataset'));
});
}; By following these steps, you can save a dataset in Superset that includes the execution of a stored procedure [1][2]. |
Beta Was this translation helpful? Give feedback.
-
How can i save a dataset that has a proc execution for the query? The database server being used has version: Azure SQL Edge 2.0.0 SQL Engine build: 16.0.5100.7245
Beta Was this translation helpful? Give feedback.
All reactions