Bigquery AI ML
GoogleOfficialPublished by Google
- Skill
- Tool integration
- Data and AI
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The BigQuery AI & ML skill provides a comprehensive interface for executing advanced data analytics, machine learning, and generative AI tasks directly inside BigQuery using SQL. It enables users to perform complex operations like time-series forecasting, anomaly detection, semantic search, and LLM-based content generation without needing to export data to external environments. The skill covers a wide range of built-in functions, including zero-shot models for forecasting and classification, as well as tools for statistical analysis and causal inference.
What it does
- Performs zero-shot time-series forecasting and anomaly detection.
- Executes LLM-based text summarization, classification, and semantic scoring.
- Conducts causal effect analysis on time-series data.
- Generates descriptive statistics and correlation matrices for datasets.
- Enables semantic and vector search capabilities within SQL.
- Extracts trends and seasonality components from historical data.
When to use it
- When you need to perform ML or GenAI tasks directly on data stored in BigQuery.
- When you want to avoid moving data out of BigQuery for analysis or model inference.
- When you need to analyze time-series data for shifts, trends, or causal impacts.
- When you need to perform semantic operations like summarization or classification at scale.
- When you need to identify key drivers behind metric changes in your data.
Advantages
- Seamless integration with existing BigQuery SQL workflows.
- Eliminates the need for complex data pipelines to external ML services.
- Supports zero-shot learning for rapid insights without custom model training.
- Scalable processing for large datasets directly within the database engine.
- Unified syntax for both traditional statistical analysis and modern generative AI.
Usage examples
- “How can I forecast future values for my sales data in BigQuery?”
- The agent will guide you to use the AI.FORECAST function, explaining how to specify your data column, timestamp column, and the required forecast horizon.
- “Summarize the sentiment of my customer reviews stored in a BigQuery table.”
- The agent will demonstrate how to use the AI.AGG function with a natural language instruction to synthesize sentiment across grouped rows.
- “Detect anomalies in my server log time-series data.”
- The agent will provide a query using AI.DETECT_ANOMALIES to identify isolated point anomalies in your time-series data.
- “Find the key drivers for a drop in website traffic.”
- The agent will show you how to use the AI.KEY_DRIVERS function to attribute metric changes to specific dimensional segments.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/google/bigquery-ai-ml/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip bigquery-ai-ml.zip -d .agents/skills
Documentation by Google
BigQuery AI & ML
BigQuery integrates with Vertex AI to provide powerful machine learning and
generative AI capabilities directly within SQL queries using built-in functions
like AI.FORECAST, AI.KEY_DRIVERS, AI.DETECT_ANOMALIES, and AI.GENERATE.
Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read Usage Attribution. For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix gcloud with
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-ai-ml)"
and append agent-skills/1.0 (skill:bigquery-ai-ml) to User-Agent headers.
Function Selection & Reference Directory
| Function | Reference | SQL Shape | Requires CREATE MODEL or CREATE VECTOR INDEX? | When to Use & Disambiguation |
|---|---|---|---|---|
AI.AGG | ai_agg.md | Aggregate | No | Multi-row semantic aggregation with GROUP BY; synthesizes one summary string across many rows (unlike per-row AI.GENERATE). |
AI.CAUSAL_EFFECT | ai_causal_effect.md | TVF | No | Quantifies counterfactual post-intervention impact on a time series after a specific treatment timestamp. |
AI.CLASSIFY | ai_classify.md | Scalar | No | Semantic classification of text or multimodal unstructured data into predefined category labels. |
AI.DETECT_ANOMALIES | ai_detect_anomalies.md | TVF | No | Zero-shot TimesFM detector for isolated time-series point anomalies/outliers (use ML.DETECT_CHANGE_POINTS for sustained shifts). |
AI.EVALUATE | ai_evaluate.md | TVF | No | Zero-shot TimesFM time-series forecast evaluation/backtesting against a historical holdout split. |
AI.FORECAST | ai_forecast.md | TVF | No | Zero-shot TimesFM time-series forecasting without training a custom model. |
AI.GENERATE | ai_generate.md | Scalar | No | Default for per-row LLM text or multimodal structured extraction (output_schema); returns STRUCT. Prefer over AI.GENERATE_TABLE. |
AI.GENERATE_EMBEDDING | ai_generate_embedding.md | TVF | Yes | Batch generates ARRAY<FLOAT64> vector embeddings for text or visual content using a remote embedding model. |
AI.GENERATE_TABLE | ai_generate_table.md | TVF | Yes | Table-valued structured extraction (FROM clause); only use instead of AI.GENERATE when a remote model + TVF is explicitly needed. |
AI.IF | ai_if.md | Scalar | No | Evaluates boolean semantic conditions (BOOL) on text or multimodal data for WHERE/CASE/JOIN filtering (do not use AI.GENERATE_TABLE). |
AI.KEY_DRIVERS | ai_key_drivers.md | TVF | No | Default one-step attribution of dimensional segments driving metric changes (interest_label_col TRUE vs. FALSE). Prefer over CONTRIBUTION_ANALYSIS. |
AI.PREDICT | ai_predict.md | TVF | No | Zero-shot TabFM foundation model for tabular classification or regression without training and managing custom models. |
AI.SCORE | ai_score.md | Scalar | No | Assigns a continuous FLOAT64 semantic score to text or multimodal data for ranking or sorting (ORDER BY). |
AI.SEARCH | ai_search.md | TVF | No | Simplified semantic search using a raw string query on tables with autonomous background embeddings (AI.EMBED generated column). |
AI.SIMILARITY | ai_similarity.md | Scalar | No | Computes an on-the-fly semantic similarity score (FLOAT64) between two text or multimodal inputs without stored embeddings. |
Remote Models | remote_models.md | CREATE MODEL | Yes | Creates a Vertex AI REMOTE WITH CONNECTION DEFAULT model entity for functions that require one (AI.GENERATE_TABLE, AI.GENERATE_EMBEDDING, VECTOR_SEARCH). |
CONTRIBUTION_ANALYSIS | ml_contribution_analysis.md | CREATE MODEL | Yes | Model-based driver analysis (CREATE MODEL ... OPTIONS(MODEL_TYPE='CONTRIBUTION_ANALYSIS') + ML.GET_INSIGHTS). Use AI.KEY_DRIVERS unless a MODEL entity is required. |
ML.CORRELATION | ml_correlation.md | TVF | No | Calculates statistical correlation coefficients between numeric columns, optionally sliced by dimensions. |
ML.DESCRIBE_DATA | ml_describe_data.md | TVF | No | Generates descriptive statistics (e.g., count, mean, median, min, max, stddev, quantiles, nulls, top values) for columns in a table or subquery. |
ML.DETECT_CHANGE_POINTS | ml_detect_change_points.md | TVF | No | Detects structural breaks or sustained shifts ([begin_timestamp, end_timestamp] intervals) in a time series. |
ML.SEASONALITY | ml_seasonality.md | TVF | No | Extracts recurring periodic/seasonal components from a historical time series. |
ML.TREND | ml_trend.md | TVF | No | Extracts the smoothed long-term trend component from a historical time series. |
VECTOR_SEARCH | vector_search.md | TVF | Yes | Searches pre-computed ARRAY<FLOAT64> embedding columns between a base table and query table (paired with AI.GENERATE_EMBEDDING, unlike AI.SEARCH). |
Related Skills
BigQuery Basics Skill: SKILL.md file for core BigQuery concepts, resource management, CLI, and client libraries.
Files
- ATTRIBUTION.mdAdded by AutoGineer846 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md8.8 KiB
- references/ai_agg.md3.5 KiB
- references/ai_causal_effect.md11.2 KiB
- references/ai_classify.md3.7 KiB
- references/ai_detect_anomalies.md5.0 KiB
- references/ai_evaluate.md2.2 KiB
- references/ai_forecast.md11.1 KiB
- references/ai_generate.md3.4 KiB
- references/ai_generate_embedding.md2.0 KiB
- references/ai_generate_table.md3.3 KiB
- references/ai_if.md2.0 KiB
- references/ai_key_drivers.md4.6 KiB
- references/ai_predict.md8.5 KiB
- references/ai_score.md1.9 KiB
- references/ai_search.md3.7 KiB
- references/ai_similarity.md2.7 KiB
- references/attribution.md1.8 KiB
- references/ml_contribution_analysis.md4.8 KiB
- references/ml_correlation.md8.9 KiB
- references/ml_describe_data.md5.1 KiB
- references/ml_detect_change_points.md5.5 KiB
- references/ml_seasonality.md6.6 KiB
- references/ml_trend.md4.1 KiB
- references/remote_models.md1.1 KiB
- references/vector_search.md4.0 KiB
references/ai_forecast.md
BigQuery AI.Forecast
AI.FORECAST leverages the pre-trained TimesFM foundation model to generate
forecasts without the need to train and manage custom models.
It has two distinct modes, which take different arguments and return different output schemas:
Univariate (
TimesFM 2.0,2.5,3.0): forecasts a single target column, specified withdata_col. See section 1.Multivariate (
TimesFM 3.0only): forecasts several target columns in one call, specified withtarget_cols, and optionally conditions on past and future covariate columns. See section 2.
data_col and target_cols are mutually exclusive. Pick the matching section
below and do not mix arguments or output columns between the two modes.
Choose the mode from the number of target columns, not from the model version.
For a single target column, use univariate data_col, including with
TimesFM 3.0. Never pass a one-element array to target_cols. The one
exception is covariates: past_covariate_cols and future_covariate_cols are
only available in multivariate mode, so a forecast that uses covariates must use
target_cols even when it has a single target column.
1. Univariate Forecasting
1.1 Syntax
SELECT
*
FROM
AI.FORECAST(
{ TABLE `project.dataset.table` | (QUERY_STATEMENT) },
data_col => 'DATA_COL',
timestamp_col => 'TIMESTAMP_COL'
[, model => 'MODEL']
[, id_cols => ID_COLS]
[, horizon => HORIZON]
[, confidence_level => CONFIDENCE_LEVEL]
[, output_historical_time_series => OUTPUT_HISTORICAL_TIME_SERIES]
[, context_window => CONTEXT_WINDOW]
)1.2 Input Arguments
| Argument | Requirement | Type | Description |
|---|---|---|---|
input_data | Required | The source table or subquery containing historical data. | |
data_col | Required | String | The numeric column to predict. |
timestamp_col | Required | String | The column containing dates/timestamps. |
id_cols | Optional | Array<String> | Grouping columns for multiple series (e.g., ['store_id']). |
horizon | Optional | Int64 | Number of future points to predict. Defaults to 10. The valid input range is [1, 10,000] for 'TimesFM 2.0' and 'TimesFM 2.5', and [1, 1024] for 'TimesFM 3.0' |
confidence_level | Optional | Float64 | Confidence interval (0 to 1). Defaults to 0.95. |
model | Optional | String | Model version. Allowed options are 'TimesFM 2.0', 'TimesFM 2.5', and 'TimesFM 3.0', with 'TimesFM 2.5' preferred. |
context_window | Optional | Int64 | The number of historical data points the model uses to forecast. The min value is 64 and the max value is 2048 for 'TimesFM 2.0'. The min value is 64 and the max value is 15360 for 'TimesFM 2.5'. For 'TimesFM 3.0' the value must be a multiple of 32 between 64 and 2048. If not set, the model determines this automatically. |
1.3 Output Schema
The schema adjusts based on the output_historical_time_series flag.
| Column | Type | Included if output_historical_time_series=FALSE | Included if output_historical_time_series=TRUE | Description |
|---|---|---|---|---|
id_cols | (As Input) | Yes | Yes | Original identifiers for the series. |
forecast_timestamp | TIMESTAMP | Yes | No | Timestamp for predicted points. |
forecast_value | FLOAT64 | Yes | No | The 50% quantile (median) prediction. |
time_series_timestamp | TIMESTAMP | No | Yes | Uniform timestamp column for both history and forecast. |
time_series_data | FLOAT64 | No | Yes | Merged column: actual values for history, median for forecast. |
time_series_type | STRING | No | Yes | Label: 'history' or 'forecast'. |
prediction_interval_lower_bound | FLOAT64 | Yes | Yes | Lower bound (NULL for historical rows). |
prediction_interval_upper_bound | FLOAT64 | Yes | Yes | Upper bound (NULL for historical rows). |
confidence_level | FLOAT64 | Yes | Yes | The constant confidence level used. |
ai_forecast_status | STRING | Yes | Yes | Error messages or empty string on success. A minimum of 3 data points is required. |
1.4 Examples
Univariate forecast returning history alongside the forecast:
WITH
citibike_trips AS (
SELECT EXTRACT(DATE FROM starttime) AS date, usertype, COUNT(*) AS num_trips
FROM `bigquery-public-data.new_york.citibike_trips`
GROUP BY date, usertype
)
SELECT *
FROM
AI.FORECAST(
TABLE citibike_trips,
data_col => 'num_trips',
timestamp_col => 'date',
id_cols => ['usertype'],
horizon => 30,
model => 'TimesFM 2.5',
output_historical_time_series => true);2. Multivariate Forecasting (TimesFM 3.0)
Multivariate forecasting predicts several target columns in a single call, and
can condition the forecast on covariate columns. It requires
model => 'TimesFM 3.0'.
Use this mode when there are two or more target columns, or when the forecast
conditions on past_covariate_cols or future_covariate_cols. For a single
target column without covariates, use section 1 instead.
2.1 Syntax
SELECT
*
FROM
AI.FORECAST(
{ TABLE `project.dataset.table` | (QUERY_STATEMENT) },
target_cols => TARGET_COLS,
timestamp_col => 'TIMESTAMP_COL',
model => 'TimesFM 3.0'
[, id_cols => ID_COLS]
[, horizon => HORIZON]
[, past_covariate_cols => PAST_COVARIATE_COLS]
[, future_covariate_cols => FUTURE_COVARIATE_COLS]
[, confidence_level => CONFIDENCE_LEVEL]
[, output_historical_time_series => OUTPUT_HISTORICAL_TIME_SERIES]
[, context_window => CONTEXT_WINDOW]
)2.2 Input Arguments
| Argument | Requirement | Type | Description |
|---|---|---|---|
input_data | Required | Table/Query | The source table or subquery containing the data to forecast. |
target_cols | Required | Array of String | The list of numeric target columns to predict simultaneously, for example ['num_trips', 'avg_duration']. Must not be combined with data_col. |
timestamp_col | Required | String | The column containing dates/timestamps. Supported types are TIMESTAMP, DATE, and DATETIME. |
model | Required | String | Must be 'TimesFM 3.0'. |
id_cols | Optional | Array of String | Grouping column names for multiple time series, for example ['store_id']. The referenced columns in the source table can be STRING or INT64. |
past_covariate_cols | Optional | Array of String | Historical-only covariate columns, for example ['foot_traffic']. Values are only known over the historical period. |
future_covariate_cols | Optional | Array of String | Covariate columns known in advance, for example ['is_holiday']. Values must be populated across both the historical period and the forecast horizon. |
horizon | Optional | Int64 | Number of future time series points to predict. Defaults to 10. The valid range is [1, 1024]. |
confidence_level | Optional | Float64 | Percentage of future values falling in the prediction interval. The valid range is [0, 1). Defaults to 0.95. |
output_historical_time_series | Optional | Bool | Determines whether input data is returned along with forecasted data. Defaults to FALSE. |
context_window | Optional | Int64 | Number of historical points the model uses. Any multiple of 32 between 64 and 2048. Defaults to 2048. |
2.3 Output Schema
The multivariate output returns one STRUCT column per entry in target_cols,
named after that target column:
| Column | Type | Description |
|---|---|---|
id_cols | (As Input) | Original identifiers for the series. |
<timestamp_col> | TIMESTAMP | Timestamp for the data point. Keeps the original name of the timestamp column from the input table, for example date. |
<target_col> | STRUCT | One STRUCT per target column, with fields value (FLOAT64, the 50% quantile prediction, or the historical value when historical output is enabled), prediction_interval_lower_bound (FLOAT64, NULL for historical rows), and prediction_interval_upper_bound (FLOAT64, NULL for historical rows). |
time_series_type | STRING | Included when output_historical_time_series=TRUE. Label of either 'history' or 'forecast'. |
confidence_level | FLOAT64 | The constant confidence level used. Defaults to 0.95. |
ai_forecast_status | STRING | Error messages, or an empty string on success. |
Note that multivariate output keeps the original timestamp column name, while
univariate output renames it to forecast_timestamp or time_series_timestamp.
2.4 Examples
Forecasting two target columns at once, unnesting each STRUCT:
WITH
citibike_trips AS (
SELECT
EXTRACT(DATE FROM starttime) AS date,
usertype,
COUNT(*) AS num_trips,
AVG(tripduration) AS avg_duration
FROM `bigquery-public-data.new_york.citibike_trips`
GROUP BY date, usertype
)
SELECT
date,
usertype,
num_trips.value AS num_trips_forecast,
num_trips.prediction_interval_lower_bound AS trips_lower_bound,
num_trips.prediction_interval_upper_bound AS trips_upper_bound,
avg_duration.value AS avg_duration_forecast,
avg_duration.prediction_interval_lower_bound AS duration_lower_bound,
avg_duration.prediction_interval_upper_bound AS duration_upper_bound
FROM
AI.FORECAST(
TABLE citibike_trips,
target_cols => ['num_trips', 'avg_duration'],
timestamp_col => 'date',
id_cols => ['usertype'],
horizon => 30,
model => 'TimesFM 3.0');Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/cloud/bigquery-ai-ml · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google or Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download bigquery-ai-ml.zip