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://mp-staging.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/ml_correlation.md
BigQuery ML.CORRELATION
ML.CORRELATION is a Table-Valued Function (TVF) that calculates the
statistical correlation between a target column and one or more target
correlation columns, optionally sliced by various dimensions.
Syntax Reference
ML.CORRELATION(
{ TABLE TABLE_NAME | (QUERY_STATEMENT) },
target_col => TARGET_COL,
target_correlation_cols => TARGET_CORRELATION_COLS
[, dimension_cols => DIMENSION_COLS ]
[, method => METHOD ]
)Input Arguments
| Argument | Requirement | Type | Description |
|---|---|---|---|
input_data (positional) | Required | The source table or query containing the data to analyze. | |
target_col | Required | STRING | The name of the numerical column to be correlated. |
target_correlation_cols | Required | STRING or ARRAY<STRING> | The name of the numerical columns to correlate against the target_col. |
dimension_cols | Optional | STRING or ARRAY<STRING> | A value that contains the names of columns to slice the data by. The function calculates correlations for every combination of these dimensions (Max: 12 columns). Supported Types: Any Groupable data type. Unsupported: ARRAY, STRUCT, JSON, GEOGRAPHY. |
method | Optional | STRING | The correlation method: PEARSON (default), SPEARMAN, or KENDALL. The KENDALL method has O(N^2) performance implications on massive tables. For large datasets, it is highly recommended to use PEARSON or SPEARMAN. |
Note on Reserved Column Names: The column names used in arguments must not
overlap with the reserved output column names: segment, target_col,
corr_col, correlation, segment_size, segment_proportion.
Output Schema
| Column | Type | Description |
|---|---|---|
segment | `ARRAY<STRUCT<dimension_col | Identifies the |
| : : STRING, dimension_value : specific : | ||
| : : JSON>>` : combination of : | ||
| : : : dimension names and : | ||
| : : : values used to : | ||
| : : : group the data for : | ||
| : : : this row. : | ||
<dimension_cols> | Varies | Columns |
| : : : corresponding to : | ||
| : : : each dimension in : | ||
: : : dimension_cols. : | ||
target_col | STRING | The name of the |
| : : : target column. : | ||
corr_col | STRING | The name of the |
| : : : column being : | ||
| : : : correlated against : | ||
| : : : the target. : | ||
correlation | FLOAT64 | The calculated |
| : : : correlation : | ||
| : : : coefficient. : | ||
segment_size | INT64 | The number of rows |
| : : : in the segment. : | ||
segment_proportion | FLOAT64 | A value that |
| : : : contains the : | ||
| : : : fraction of total : | ||
| : : : rows in the input : | ||
| : : : table that belong : | ||
| : : : to this segment. : |
Note: Results are sorted by segment_size (descending) and then corr_col
(ascending) by default.
Examples
The following examples show how to use the ML.CORRELATION function and use the
my_dataset.marketing_sample table:
CREATE OR REPLACE TABLE my_dataset.marketing_sample AS (
-- New York data
SELECT 'USA' AS country, 'New York' AS city, 'Electronics' AS product_category, 100 AS ad_spend, 150 AS budget, 1000 AS revenue UNION ALL
SELECT 'USA', 'New York', 'Electronics', 150, 200, 1500 UNION ALL
SELECT 'USA', 'New York', 'Apparel', 200, 250, 2000 UNION ALL
-- Seattle data
SELECT 'USA', 'Seattle', 'Apparel', 200, 250, 2000 UNION ALL
SELECT 'USA', 'Seattle', 'Apparel', 300, 350, 3000 UNION ALL
-- London data (Genuine NULL country)
SELECT NULL, 'London', 'Electronics', 100, 120, 500 UNION ALL
SELECT NULL, 'London', 'Electronics', 200, 220, 900 UNION ALL
-- Missing city data (Genuine NULL city)
SELECT NULL, NULL, 'Apparel', 200, 200, 1000 UNION ALL
SELECT NULL, NULL, 'Apparel', 250, 250, 1200
);
/*---------+----------+------------------+----------+---------+---------+
| country | city | product_category | ad_spend | budget | revenue |
+---------+----------+------------------+----------+---------+---------+
| USA | New York | Electronics | 100 | 150 | 1000 |
| USA | New York | Electronics | 150 | 200 | 1500 |
| USA | New York | Apparel | 200 | 250 | 2000 |
| USA | Seattle | Apparel | 200 | 250 | 2000 |
| USA | Seattle | Apparel | 300 | 350 | 3000 |
| null | London | Electronics | 100 | 120 | 500 |
| null | London | Electronics | 200 | 220 | 900 |
| null | null | Apparel | 200 | 200 | 1000 |
| null | null | Apparel | 250 | 250 | 1200 |
+---------+----------+------------------+----------+---------+---------*/Calculate Pearson correlation
The following example calculates the Pearson correlation between revenue and
ad_spend from the table my_dataset.marketing_sample and uses country as a
dimension column:
SELECT
country,
segment,
correlation,
segment_size
FROM ML.CORRELATION(
TABLE my_dataset.marketing_sample,
target_col => 'revenue',
target_correlation_cols => 'ad_spend',
dimension_cols => ['country']
);
/*---------+---------------------------------------------------------------+-------------+--------------+
| country | segment | correlation | segment_size |
+---------+---------------------------------------------------------------+-------------+--------------+
| 'USA' | [{dimension_col: 'country', dimension_value: 'USA'}] | 1.0 | 2 |
| NULL | [{dimension_col: 'country', dimension_value: null}] | 1.0 | 2 |
| NULL | [] | 0.688 | 4 |
+---------+---------------------------------------------------------------+-------------+--------------*/The second row of the result corresponds to a genuine NULL in the input data
for country because the dimension_value field is NULL. The third row of the
result contains NULL for country because it corresponds to aggregation over
all countries.
Calculate correlation for multiple columns
The following example calculates the correlation between revenue and
ad_spend and budget, sliced by city and product_category, from the table
my_dataset.marketing_sample:
SELECT *
FROM
ML.CORRELATION(
(SELECT * FROM my_dataset.marketing_sample WHERE country = 'USA'),
target_col => 'revenue',
target_correlation_cols => ['ad_spend', 'budget'],
dimension_cols => ['city', 'product_category']
);Distinguish between global aggregates and missing data
The following example shows how to use the segment column to label your rows
clearly in a report:
SELECT
-- Create a clean label for reporting
CASE
-- If 'city' is NULL and not in the segment array, it's a total
WHEN city IS NULL AND NOT EXISTS(SELECT 1 FROM UNNEST(segment) s WHERE s.dimension_col = 'city')
THEN 'ALL CITIES (Global)'
-- If 'city' is NULL and in the segment array, it's missing data
WHEN city IS NULL
THEN 'UNKNOWN CITY'
ELSE city
END AS city_label,
correlation,
segment_size
FROM ML.CORRELATION(
TABLE my_dataset.marketing_sample,
target_col => 'revenue',
target_correlation_cols => 'ad_spend',
dimension_cols => ['city']
);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.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download bigquery-ai-ml.zip