(sql)
| 420 | } |
| 421 | |
| 422 | const explainSql = (sql) => { |
| 423 | setIsExplainSqlLoading(true) |
| 424 | |
| 425 | const options = { |
| 426 | method: 'POST', |
| 427 | headers: { 'content-type': 'application/json' }, |
| 428 | body: JSON.stringify({ |
| 429 | sql, |
| 430 | session_id: sessionId, |
| 431 | }), |
| 432 | } |
| 433 | |
| 434 | fetch(api_endpoint + '/api/explain_sql', options) |
| 435 | .then((response) => response.json()) |
| 436 | .then((response) => { |
| 437 | setSqlExplanation(response.explanation) |
| 438 | setIsExplainSqlLoading(false) |
| 439 | }) |
| 440 | .catch((err) => { |
| 441 | setSqlExplanation() |
| 442 | logSentryError({ query }, err) |
| 443 | setIsExplainSqlLoading(false) |
| 444 | capturePosthog('explainSql_backend_error', { |
| 445 | error: err, |
| 446 | }) |
| 447 | setErrorMessage(err.message || err) |
| 448 | console.error(err) |
| 449 | }) |
| 450 | } |
| 451 | |
| 452 | const getTables = async (natural_language_query) => { |
| 453 | setIsGetTablesLoading(true) |
no test coverage detected