mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
chore: Hugh/migrate estimate query cost to v1 (#23226)
Co-authored-by: Diego Medina <diegomedina24@gmail.com>
This commit is contained in:
@@ -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 }),
|
||||
|
||||
Reference in New Issue
Block a user