run_query
Execute read-only SELECT queries on BigQuery with dry-run cost estimation, returning rows only after confirming expensive scans.
Instructions
Run a read-only (SELECT/WITH) SQL query against BigQuery and return rows.
Cost safety: the query is ALWAYS dry-run first to estimate how much data it
will scan. If that estimate is above the warning threshold, the query does
NOT run — instead this returns status: "confirmation_required" with the
estimated size and cost. Stop there, tell the user the estimated scan and
cost, and ask. Only re-call with confirm_expensive=true once they have
agreed: that flag records the user's decision, not yours. Queries above the
hard cap never run, even with confirmation.
Always fully-qualify tables as <project>.<dataset>.<table>, and check
get_table_schema first — a WHERE clause only limits the scan on a table
that is actually partitioned.
Args: sql: A SELECT (or WITH ... SELECT) query. max_rows: Max rows to return, to keep responses small. 0 (the default) uses the server's configured limit. confirm_expensive: Set True only after the user has agreed to a query previously flagged as costly. Leave False for the first attempt. environment: Which configured BigQuery environment to query. Omit to use the default. Call list_environments to see what exists.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| max_rows | No | ||
| environment | No | ||
| confirm_expensive | No |