SkillsMar 29, 2026·1 min read

Gemini CLI Extension: BigQuery — Data Analytics & SQL

Gemini CLI extension for BigQuery. Write SQL queries, analyze datasets, optimize performance, and manage tables.

TL;DR
Gemini CLI extension that helps you write SQL, analyze BigQuery datasets, and optimize queries.
§01

What it is

This is a Gemini CLI extension that adds BigQuery capabilities to your terminal workflow. It helps you write SQL queries, analyze datasets, optimize query performance, and manage BigQuery tables. The extension leverages Gemini models to understand your data questions and generate appropriate SQL.

It is designed for data analysts, data engineers, and developers who work with BigQuery and prefer terminal-based workflows over the web console.

§02

How it saves time or tokens

Writing complex BigQuery SQL from scratch is error-prone, especially for window functions, nested structs, and partitioned table queries. This extension generates syntactically correct BigQuery SQL from natural language descriptions. The estimated token cost is around 500 tokens per query. Time savings come from skipping the context-switch to the BigQuery web console.

§03

How to use

  1. Install the Gemini CLI and authenticate with your Google Cloud project.
  2. Add the BigQuery extension to your configuration.
  3. Describe your data question or SQL task in natural language.
  4. Review and execute the generated SQL.
# Install Gemini CLI
npm install -g @google/gemini-cli

# Authenticate with Google Cloud
gcloud auth application-default login

# Query BigQuery with natural language
gemini bigquery 'Show top 10 users by total spend in the last 30 days'

# Optimize an existing query
gemini bigquery optimize --query 'SELECT * FROM dataset.table WHERE date > CURRENT_DATE()'

# Describe a table schema
gemini bigquery describe dataset.users
§04

Example

Generating a window function query:

-- Input: 'Calculate running total of revenue by month for each product'
-- Generated SQL:
SELECT
  product_id,
  DATE_TRUNC(order_date, MONTH) AS month,
  SUM(revenue) AS monthly_revenue,
  SUM(SUM(revenue)) OVER (
    PARTITION BY product_id
    ORDER BY DATE_TRUNC(order_date, MONTH)
  ) AS running_total
FROM `project.dataset.orders`
GROUP BY product_id, month
ORDER BY product_id, month
§05

Related on TokRepo

§06

Common pitfalls

  • The extension requires proper Google Cloud authentication. Ensure your default credentials have BigQuery read access.
  • Generated SQL should always be reviewed before execution. Complex joins and aggregations may not match your exact schema.
  • Large result sets may hit BigQuery query limits. Use LIMIT clauses when exploring data.
  • Table name inference works best when you specify the full project.dataset.table path.
  • Cost awareness matters. BigQuery charges by bytes scanned. Always check the estimated bytes before running generated queries on large tables.
  • Review the official documentation before deploying to production to ensure compatibility with your specific environment and requirements.

Frequently Asked Questions

Does this extension execute queries or just generate SQL?+

The extension can both generate SQL and execute it against BigQuery, depending on the command. Use the generate mode to review SQL before running it, or the execute mode for quick ad-hoc queries.

What Google Cloud permissions are required?+

You need BigQuery Job User and BigQuery Data Viewer roles at minimum. For table management operations, BigQuery Data Editor is also required. The extension uses your application default credentials.

Can it work with datasets I have not seen before?+

Yes. The extension can describe table schemas and sample data to help you understand unfamiliar datasets before writing queries. It reads BigQuery metadata to inform its SQL generation.

How accurate is the generated SQL?+

Accuracy depends on query complexity and how well you describe the task. Simple aggregations and filters are highly accurate. Complex multi-join queries with specific business logic may need manual adjustment.

Does it support BigQuery ML?+

The extension can generate BigQuery ML statements like CREATE MODEL and ML.PREDICT, though ML queries may require additional review to ensure correct feature columns and model parameters.

Citations (3)
🙏

Source & Thanks

Created by Google. Licensed under Apache 2.0. gemini-cli-extensions/bigquery-data-analytics Part of Gemini CLI — ⭐ 99,400+

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets