GC-301e · Module 2
BigQuery & Firestore
3 min read
BigQuery integration through Gemini CLI turns the terminal into an analytics workbench. The BigQuery extension provides tools for running SQL queries, inspecting table schemas, listing datasets, and previewing query costs. The 1M context window means you can load query results directly into the conversation and ask Gemini to analyze patterns, generate visualizations descriptions, or transform the data. The workflow: "Query daily active users for the last 90 days, then identify the week-over-week trend and flag any anomalies."
Firestore operations through Gemini CLI cover the full document lifecycle: creating and querying documents, managing indexes, setting up security rules, and monitoring usage. The Firestore extension understands the NoSQL data model — collections, documents, subcollections, and composite indexes. Ask Gemini to "add a composite index on the users collection for status and createdAt, descending" and it generates the correct index definition and deploys it. For security rules, Gemini can analyze your existing rules, identify gaps, and propose improvements.
-- "Query daily active users for the last 90 days"
SELECT
DATE(event_timestamp) AS day,
COUNT(DISTINCT user_id) AS dau
FROM `my-project.analytics.events`
WHERE event_timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 90 DAY)
AND event_name = 'session_start'
GROUP BY day
ORDER BY day DESC;
-- "Show me the most expensive queries this week"
SELECT
user_email,
query,
total_bytes_processed / POW(1024, 3) AS gb_processed,
total_slot_ms / 1000 AS slot_seconds
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
ORDER BY total_bytes_processed DESC
LIMIT 20;