bigquery-ai-ml

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

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

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 models. This Skill provides the syntax, constraints, and best practices to perform these tasks directly in BigQuery SQL using built-in AI functions. ## Core Features & Use Cases - Time-Series Analysis: Generate forecasts with AI.FORECAST, detect anomalies with AI.DETECT_ANOMALIES, and evaluate model accuracy with AI.EVALUATE using the pre-trained TimesFM model. - Generative AI in SQL: Generate text with AI.GENERATE, classify content with AI.CLASSIFY, aggregate insights with AI.AGG, and extract structured data with AI.GENERATE_TABLE using Gemini endpoints. - Semantic Search & Similarity: Perform vector search with VECTOR_SEARCH, semantic search with AI.SEARCH, and compute similarity scores with AI.SIMILARITY and AI.GENERATE_EMBEDDING. - Use Case: A retail analyst wants to forecast next month's sales per store and identify which product categories drove a revenue change. The Skill guides writing AI.FORECAST queries with proper chronological data splits and AI.KEY_DRIVERS queries for contribution analysis. ## Quick Start Write a BigQuery SQL query that forecasts daily bike trips for the next 30 days using AI.FORECAST on 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 without training a model?▼

Use the AI.FORECAST table-valued function, which leverages the pre-trained TimesFM model. Provide your historical data, specify the data_col and timestamp_col arguments, and optionally set horizon and id_cols for multiple series.

How to detect anomalies in BigQuery time-series data?▼

Use AI.DETECT_ANOMALIES with a historical dataset and a target dataset to compare against. It uses the TimesFM model and returns is_anomaly flags, probability scores, and expected bounds, requiring a minimum of 3 data points per series.

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

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

Does BigQuery AI.FORECAST require a remote model or connection?▼

No, AI.FORECAST uses the pre-trained TimesFM model directly without creating a remote model. However, generative functions like AI.GENERATE_TABLE and AI.GENERATE_EMBEDDING require a remote model created with a Vertex AI connection.

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

Common causes include placing table-valued functions like AI.FORECAST 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?▼

Use AI.KEY_DRIVERS for quick key driver analysis directly as a table-valued function without creating a model. Use a CONTRIBUTION_ANALYSIS model with ML.GET_INSIGHTS when you need a persisted model entity for repeated insight retrieval.