bigquery-ai-ml

Write BigQuery SQL queries using AI functions for forecasting, anomaly detection, and text generation.

Updated Aug 26, 2026
One-click install
npx skills add https://github.com/SmileAfterBurn/pani-dumka-ai --skill bigquery-ai-ml-smileafterburn
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: bigquery-ai-ml
Source: https://github.com/SmileAfterBurn/pani-dumka-ai/tree/main/.gemini/skills/bigquery-ai-ml
Command: npx skills add https://github.com/SmileAfterBurn/pani-dumka-ai --skill bigquery-ai-ml-smileafterburn

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing correct BigQuery ML and generative AI SQL requires knowing the exact syntax, argument rules, and model routing for over a dozen AI functions, and mistakes like misplacing table-valued functions or skipping mandatory data exploration cause failed queries. ## Core Features & Use Cases - Time-Series Analysis: Generate forecasts with AI.FORECAST, detect outliers with AI.DETECT_ANOMALIES, and evaluate accuracy with AI.EVALUATE using the pre-trained TimesFM model. - Generative AI in SQL: Classify, summarize, score, and generate text or structured output directly in queries using AI.GENERATE, AI.CLASSIFY, AI.AGG, and AI.GENERATE_TABLE with Gemini endpoints. - Semantic Search & Key Drivers: Perform vector search with VECTOR_SEARCH and AI.SEARCH, compute semantic similarity, and identify metric drivers with AI.KEY_DRIVERS or contribution analysis models. - Use Case: A data analyst needs to forecast next month's sales per store and explain which segments drove a revenue change. The Skill routes them to AI.FORECAST with proper chronological data splitting, then to AI.KEY_DRIVERS for segment-level contribution analysis. ## Quick Start Use the bigquery-ai-ml skill to write a SQL query that forecasts daily bike trips for the next 30 days from the citibike public dataset.

Frequently Asked Questions about bigquery-ai-ml

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I forecast time series data in BigQuery SQL?▼

Use AI.FORECAST, a table-valued function placed in the FROM clause, with data_col and timestamp_col as required named arguments. It uses the pre-trained TimesFM model, so no custom model training is needed, and you can set horizon and id_cols for multiple series.

How to detect anomalies in BigQuery without training a model?▼

Use AI.DETECT_ANOMALIES with a historical dataset and a target dataset, specifying data_col and timestamp_col. It relies on the pre-trained TimesFM model and returns is_anomaly flags, probability scores, and expected bounds, requiring at least 3 data points.

What is the difference between AI.GENERATE and AI.GENERATE_TABLE in BigQuery?▼

AI.GENERATE is a scalar function returning a STRUCT with generated text per row, while AI.GENERATE_TABLE is a table-valued function called in the FROM clause that extracts data into a defined output_schema. AI.GENERATE_TABLE requires a remote model and an input column aliased as prompt.

Does BigQuery AI.FORECAST require creating a model first?▼

No, AI.FORECAST uses the pre-trained TimesFM foundation model directly and does not require a CREATE MODEL statement. However, generative functions like AI.GENERATE_TABLE and AI.GENERATE_EMBEDDING require a remote model created with REMOTE WITH CONNECTION pointing to a Gemini or embedding endpoint.

Why does my BigQuery AI function query fail with a syntax error?▼

Common causes include placing table-valued functions like AI.FORECAST or AI.GENERATE_TABLE outside the FROM clause, omitting the => operator for named arguments, or missing the prompt column alias in AI.GENERATE_TABLE input subqueries. Check the function routing rules before writing queries.

When should I use AI.KEY_DRIVERS versus a contribution analysis model?▼

AI.KEY_DRIVERS is a table-valued function that identifies segments driving metric changes without creating a model, limited to 12 dimension columns. The CONTRIBUTION_ANALYSIS model type with ML.GET_INSIGHTS supports up to 50 dimension columns and persists as a reusable model entity.