get_sql_status
Check the execution status and retrieve results for SQL queries in Databricks using statement IDs.
Instructions
Get the status and results of a SQL statement by statement_id
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"statement_id": "<statement_id>"
},
"name": "get_sql_status"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| statement_id | Yes |
Implementation Reference
- MCP tool handler and registration for 'get_sql_status'. Takes statement_id as input, fetches status via sql.get_statement_status helper, returns JSON result or error.
@mcp.tool() async def get_sql_status(statement_id: str) -> str: """Get the status and results of a SQL statement by statement_id""" logger.info(f"Getting status for SQL statement: {statement_id}") try: result = await sql.get_statement_status(statement_id) return json.dumps(result) except Exception as e: logger.error(f"Error getting SQL status: {str(e)}") return json.dumps({"error": str(e)}) - src/api/sql.py:140-155 (helper)Supporting utility function that performs the actual API call to Databricks /sql/statements/{statement_id} endpoint to retrieve the SQL statement status.
async def get_statement_status(statement_id: str) -> Dict[str, Any]: """ Get the status of a SQL statement. Args: statement_id: ID of the statement to check Returns: Response containing statement status Raises: DatabricksAPIError: If the API request fails """ logger.info(f"Getting status of SQL statement: {statement_id}") return make_api_request("GET", f"/api/2.0/sql/statements/{statement_id}", params={})