Antonio-RiveroMartnez commented on code in PR #34869: URL: https://github.com/apache/superset/pull/34869#discussion_r2306834468
########## superset-frontend/src/explore/components/controls/ViewQuery.tsx: ########## @@ -88,31 +92,41 @@ const ViewQuery: FC<ViewQueryProps> = props => { preloadLanguages([language]); }, [language]); - const formatCurrentQuery = useCallback(() => { + const formatCurrentQuery = useCallback(async () => { if (formattedSQL) { setShowFormatSQL(val => !val); - } else { + return; + } + let backend = exploreBackend; + if (!backend) { const queryParams = rison.encode(DATASET_BACKEND_QUERY); - SupersetClient.get({ - endpoint: `/api/v1/dataset/${datasetId}?q=${queryParams}`, - }) - .then(({ json }) => - SupersetClient.post({ - endpoint: `/api/v1/sqllab/format_sql/`, - body: JSON.stringify({ - sql, - engine: json.result.database.backend, - }), - headers: { 'Content-Type': 'application/json' }, + try { Review Comment: nit: we could have these two `try/catch` merged into just one -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org