execute_sql
Run a SQL query in the project and return the result.
This tool is restricted to only `SELECT` statements. `INSERT`, `UPDATE`, and `DELETE`
statements and stored procedures aren't allowed. If the query doesn't include a `SELECT`
statement, an error is returned. For information on creating queries, see the [GoogleSQL
documentation](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax).
The `execute_sql` tool can also have side effects if the the query invokes
[remote functions](https://cloud.google.com/bigquery/docs/remote-functions)
or [Python UDFs](https://cloud.google.com/bigquery/docs/user-defined-functions-python).
All queries that are run using the `execute_sql` tool have a label that identifies the tool
as the source. You can use this label to filter the queries using the label and value pair
`goog-mcp-server: true`.
Queries are charged to the project specified in the `project_id` field.
Example Queries:
-- Count the number of penguins in each island.
SELECT island, COUNT(*) AS population
FROM bigquery-public-data.ml_datasets.penguins GROUP BY island
-- Evaluate a bigquery ML Model.
SELECT * FROM ML.EVALUATE(MODEL `my_dataset.my_model`)
-- Evaluate BigQuery ML model on custom data
SELECT * FROM ML.EVALUATE(MODEL `my_dataset.my_model`,
(SELECT * FROM `my_dataset.my_table`))
-- Predict using BigQuery ML model:
SELECT * FROM ML.PREDICT(MODEL `my_dataset.my_model`,
(SELECT * FROM `my_dataset.my_table`))
-- Forecast data using AI.FORECAST
SELECT * FROM AI.FORECAST(TABLE `project.dataset.my_table`, data_col => 'num_trips',
timestamp_col => 'date', id_cols => ['usertype'], horizon => 30)