Run a SQL query in the project and return the result. Prefer the `execute_sql_readonly`
tool if possible.
This tool can execute any query that bigquery supports including:
* SQL Queries (`SELECT`, `INSERT`, `UPDATE`, `DELETE`, `CREATE`, etc.)
* AI/ML functions like `AI.FORECAST`, `ML.EVALUATE`, `ML.PREDICT`
* Any other query that bigquery supports.
Example Queries:
```sql
-- Insert data into a table.
INSERT INTO `my_project.my_dataset`.my_table (name, age)
VALUES ('Alice', 30);
-- Create a table.
CREATE TABLE `my_project.my_dataset`.my_table (
name STRING,
age INT64);
-- DELETE data from a table.
DELETE FROM `my_project.my_dataset`.my_table WHERE name = 'Alice';
-- Create Dataset
CREATE SCHEMA `my_project.my_dataset` OPTIONS (location = 'US');
-- Drop table
DROP TABLE `my_project.my_dataset`.my_table;
-- Drop dataset
DROP SCHEMA `my_project.my_dataset`;
-- Create Model
CREATE OR REPLACE MODEL `my_project.my_dataset.my_model`
OPTIONS (
model_type = 'LINEAR_REG'
LS_INIT_LEARN_RATE=0.15,
L1_REG=1,
MAX_ITERATIONS=5,
DATA_SPLIT_METHOD='SEQ',
DATA_SPLIT_EVAL_FRACTION=0.3,
DATA_SPLIT_COL='timestamp') AS
SELECT col1, col2, timestamp, label FROM `my_project.my_dataset.my_table`;
```
Queries executed using the `execute_sql` tool will always have the default job label
`goog-mcp-server: true` automatically set in addition to any custom `labels` provided in the
request. Queries are charged to the project specified in the `project_id` field.
Query Execution Behavior:
* If the query completes within the synchronous timeout (default 20 seconds or custom `timeout_ms`),
the tool returns `job_complete: true` and the initial result rows directly. For fast queries, `job_id` may
be omitted as no persistent background job is created; no further action or polling is needed.
* If the query takes longer than `timeout_ms`, the tool returns `job_complete: false` and a `job_id`.
In this case, use the `get_query_results` tool with `job_id` to poll until `job_complete: true`,
or use `cancel_job` to abort the running query.
* You can optionally specify `timeout_ms` to configure the maximum synchronous wait time in milliseconds
(defaults to 20,000 ms), and `job_timeout_ms` to enforce a hard server-side timeout after which
BigQuery automatically terminates the job.