bigquery-ai-ml

Write BigQuery SQL queries using built-in AI and ML functions for forecasting, anomaly detection, and generative analysis.

Updated Jan 8, 2026
One-click install
npx skills add https://github.com/arslan9024/White-Caves --skill bigquery-ai-ml-arslan9024
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: bigquery-ai-ml
Source: https://github.com/arslan9024/White-Caves/tree/main/.agents/skills/bigquery_ai_ml
Command: npx skills add https://github.com/arslan9024/White-Caves --skill bigquery-ai-ml-arslan9024

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Analysts often need machine learning and generative AI capabilities like forecasting, anomaly detection, and text generation but lack the infrastructure to train and deploy custom models. This Skill provides the syntax, constraints, and best practices for using BigQuery's built-in AI functions directly in SQL. ## Core Features & Use Cases - Time-Series Forecasting & Anomaly Detection: Use AI.FORECAST and AI.DETECT_ANOMALIES with the pre-trained TimesFM model to predict trends and find outliers without training custom models. - Generative AI in SQL: Use AI.GENERATE, AI.GENERATE_TABLE, AI.AGG, and AI.CLASSIFY to summarize, categorize, and extract structured data from text and images via Gemini endpoints. - Semantic Search & Embeddings: Use AI.GENERATE_EMBEDDING, VECTOR_SEARCH, AI.SEARCH, and AI.SIMILARITY for semantic search, recommendations, and similarity scoring. - Use Case: A data analyst wants to forecast next month's sales per store and detect unusual dips. They use AI.FORECAST with id_cols for per-store series, then AI.DETECT_ANOMALIES to flag outliers, all in pure BigQuery SQL. ## Quick Start Write a BigQuery SQL query that uses AI.FORECAST to predict daily sales for the next 30 days from my sales table.

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 without training a model?▼

Use the AI.FORECAST table-valued function, which relies on the pre-trained TimesFM model. Provide your historical table or query, specify data_col and timestamp_col, and optionally set horizon, id_cols for multiple series, and confidence_level.

How do I detect anomalies in BigQuery time series data?▼

Use AI.DETECT_ANOMALIES with a historical dataset and a target dataset, specifying data_col and timestamp_col. It uses the TimesFM model and returns is_anomaly flags, probability scores, and expected bounds. At least 3 data points are required.

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 structured output into a defined output_schema. AI.GENERATE_TABLE requires a remote model and an input column aliased as prompt.

Does BigQuery AI.GENERATE require a connection to Vertex AI?▼

Yes, generative and embedding functions use remote models connected to Vertex AI endpoints like gemini-2.5-flash. You can use REMOTE WITH CONNECTION DEFAULT so BigQuery uses a default connection in the model's region, or specify a fully qualified connection ID.

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 quotes around the output_schema string. Check the function's syntax reference for required argument formats.

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

AI.KEY_DRIVERS is a table-valued function that identifies key segments driving metric changes directly in a query without creating a model. CONTRIBUTION_ANALYSIS requires a CREATE MODEL statement and ML.GET_INSIGHTS, suiting reusable, persisted analysis workflows.