chore: Hugh/migrate estimate query cost to v1 (#23226)

Co-authored-by: Diego Medina <diegomedina24@gmail.com>
This commit is contained in:
Hugh A. Miles II
2023-03-17 18:02:25 -06:00
committed by GitHub
parent 022213972b
commit 8fa77adf9a
10 changed files with 329 additions and 15 deletions

View File

@@ -184,18 +184,20 @@ export function estimateQueryCost(queryEditor) {
const { dbId, schema, sql, selectedText, templateParams } =
getUpToDateQuery(getState(), queryEditor);
const requestSql = selectedText || sql;
const endpoint =
schema === null
? `/superset/estimate_query_cost/${dbId}/`
: `/superset/estimate_query_cost/${dbId}/${schema}/`;
const postPayload = {
database_id: dbId,
schema,
sql: requestSql,
template_params: JSON.parse(templateParams || '{}'),
};
return Promise.all([
dispatch({ type: COST_ESTIMATE_STARTED, query: queryEditor }),
SupersetClient.post({
endpoint,
postPayload: {
sql: requestSql,
templateParams: JSON.parse(templateParams || '{}'),
},
endpoint: '/api/v1/sqllab/estimate/',
body: JSON.stringify(postPayload),
headers: { 'Content-Type': 'application/json' },
})
.then(({ json }) =>
dispatch({ type: COST_ESTIMATE_RETURNED, query: queryEditor, json }),