Generated banner for Bigquery AI ML
Generated logo for Bigquery AI ML

Bigquery AI ML

GoogleOfficialPublished by Google

  • Skill
  • Tool integration
  • Data and AI
  • Apache-2.0
  • No issues found

From the author

Leverages BigQuery's built-in machine learning and GenAI capabilities for advanced data analytics. Use when you need to write SQL queries that perform time-series forecasting, predict values, detect outliers or anomalies, find key drivers, perform semantic search or vector search, classify text, calculate similarity, summarize content, translate language, evaluate models, filter by semantic conditions, measure the causal effect of an intervention, compute correlations between columns, generate descriptive statistics and table distribution profiles, detect change points or structural breaks, extract trend or seasonality components, or leverage generative AI capabilities in BigQuery. Do not use for general BigQuery dataset, table, or job management requests.
— the description by Google

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

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/google/bigquery-ai-ml/download
  2. Unzip 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

FunctionReferenceSQL ShapeRequires CREATE MODEL or CREATE VECTOR INDEX?When to Use & Disambiguation
AI.AGGai_agg.mdAggregateNoMulti-row semantic aggregation with GROUP BY; synthesizes one summary string across many rows (unlike per-row AI.GENERATE).
AI.CAUSAL_EFFECTai_causal_effect.mdTVFNoQuantifies counterfactual post-intervention impact on a time series after a specific treatment timestamp.
AI.CLASSIFYai_classify.mdScalarNoSemantic classification of text or multimodal unstructured data into predefined category labels.
AI.DETECT_ANOMALIESai_detect_anomalies.mdTVFNoZero-shot TimesFM detector for isolated time-series point anomalies/outliers (use ML.DETECT_CHANGE_POINTS for sustained shifts).
AI.EVALUATEai_evaluate.mdTVFNoZero-shot TimesFM time-series forecast evaluation/backtesting against a historical holdout split.
AI.FORECASTai_forecast.mdTVFNoZero-shot TimesFM time-series forecasting without training a custom model.
AI.GENERATEai_generate.mdScalarNoDefault for per-row LLM text or multimodal structured extraction (output_schema); returns STRUCT. Prefer over AI.GENERATE_TABLE.
AI.GENERATE_EMBEDDINGai_generate_embedding.mdTVFYesBatch generates ARRAY<FLOAT64> vector embeddings for text or visual content using a remote embedding model.
AI.GENERATE_TABLEai_generate_table.mdTVFYesTable-valued structured extraction (FROM clause); only use instead of AI.GENERATE when a remote model + TVF is explicitly needed.
AI.IFai_if.mdScalarNoEvaluates boolean semantic conditions (BOOL) on text or multimodal data for WHERE/CASE/JOIN filtering (do not use AI.GENERATE_TABLE).
AI.KEY_DRIVERSai_key_drivers.mdTVFNoDefault one-step attribution of dimensional segments driving metric changes (interest_label_col TRUE vs. FALSE). Prefer over CONTRIBUTION_ANALYSIS.
AI.PREDICTai_predict.mdTVFNoZero-shot TabFM foundation model for tabular classification or regression without training and managing custom models.
AI.SCOREai_score.mdScalarNoAssigns a continuous FLOAT64 semantic score to text or multimodal data for ranking or sorting (ORDER BY).
AI.SEARCHai_search.mdTVFNoSimplified semantic search using a raw string query on tables with autonomous background embeddings (AI.EMBED generated column).
AI.SIMILARITYai_similarity.mdScalarNoComputes an on-the-fly semantic similarity score (FLOAT64) between two text or multimodal inputs without stored embeddings.
Remote Modelsremote_models.mdCREATE MODELYesCreates a Vertex AI REMOTE WITH CONNECTION DEFAULT model entity for functions that require one (AI.GENERATE_TABLE, AI.GENERATE_EMBEDDING, VECTOR_SEARCH).
CONTRIBUTION_ANALYSISml_contribution_analysis.mdCREATE MODELYesModel-based driver analysis (CREATE MODEL ... OPTIONS(MODEL_TYPE='CONTRIBUTION_ANALYSIS') + ML.GET_INSIGHTS). Use AI.KEY_DRIVERS unless a MODEL entity is required.
ML.CORRELATIONml_correlation.mdTVFNoCalculates statistical correlation coefficients between numeric columns, optionally sliced by dimensions.
ML.DESCRIBE_DATAml_describe_data.mdTVFNoGenerates descriptive statistics (e.g., count, mean, median, min, max, stddev, quantiles, nulls, top values) for columns in a table or subquery.
ML.DETECT_CHANGE_POINTSml_detect_change_points.mdTVFNoDetects structural breaks or sustained shifts ([begin_timestamp, end_timestamp] intervals) in a time series.
ML.SEASONALITYml_seasonality.mdTVFNoExtracts recurring periodic/seasonal components from a historical time series.
ML.TRENDml_trend.mdTVFNoExtracts the smoothed long-term trend component from a historical time series.
VECTOR_SEARCHvector_search.mdTVFYesSearches pre-computed ARRAY<FLOAT64> embedding columns between a base table and query table (paired with AI.GENERATE_EMBEDDING, unlike AI.SEARCH).
  • BigQuery Basics Skill: SKILL.md file for core BigQuery concepts, resource management, CLI, and client libraries.

Files

references/ml_contribution_analysis.md

Contribution Analysis

Contribution analysis, also called key driver analysis, is a method used to generate insights about changes to key metrics in your multi-dimensional data.

Syntax

To use contribution analysis in BigQuery ML, create a contribution analysis model with the CREATE MODEL statement.

After you have created a contribution analysis model, you can use the ML.GET_INSIGHTS function to retrieve the metric information calculated by the model.

CREATE MODEL Syntax
CREATE OR REPLACE MODEL `project.dataset.model_name`
OPTIONS (
  MODEL_TYPE = 'CONTRIBUTION_ANALYSIS',
  CONTRIBUTION_METRIC = 'contribution_metric',
  IS_TEST_COL = 'is_test_col'
  [, DIMENSION_ID_COLS = dimension_column_array]
  [, MIN_APRIORI_SUPPORT = min_apriori_support]
  [, TOP_K_INSIGHTS_BY_APRIORI_SUPPORT = top_k_insights_by_apriori_support]
  [, PRUNING_METHOD = {'NO_PRUNING', 'PRUNE_REDUNDANT_INSIGHTS'}]
)
AS query_statement;
Options
OptionRequirementTypeDescription
MODEL_TYPERequiredStringMust be 'CONTRIBUTION_ANALYSIS'.
CONTRIBUTION_METRICRequiredStringThe metric to analyze. Supported metric is SUM(metric_column_name).
IS_TEST_COLRequiredStringThe name of the boolean column that distinguishes test data (TRUE) from control data (FALSE).
DIMENSION_ID_COLSOptionalArray<String>The columns to use as dimensions for segmenting the data. Defaults to all columns in the input data that aren't specified in other options. Restricted to columns of type INT64, BOOL, or STRING. Limited to a max of 50 columns.
MIN_APRIORI_SUPPORTOptionalFloat64Minimum support threshold to prune small segments. Cannot be used with TOP_K_INSIGHTS_BY_APRIORI_SUPPORT. Defaults to 0.1 if neither is specified. The value is in the range of [0, 1].
TOP_K_INSIGHTS_BY_APRIORI_SUPPORTOptionalInt64The maximum number of insights to output with the highest apriori support value. Cannot be used with MIN_APRIORI_SUPPORT. This value should be within the interval [1, 1,000,000]
PRUNING_METHODOptionalStringThe pruning method used to filter insights. Supported: 'NO_PRUNING', 'PRUNE_REDUNDANT_INSIGHTS'. Defaults to 'NO_PRUNING'. PRUNE_REDUNDANT_INSIGHTS prunes redundant segments, excluding the all segment. Two segments are redundant if two conditions are met: 1) their metric values are equal 2) The dimension IDs and corresponding values of one row are a subset of the dimension IDs and corresponding values of the other. In this case, the row with more dimension IDs (the more descriptive row) is kept.

ML.GET_INSIGHTS Syntax

Use ML.GET_INSIGHTS to retrieve the results from the model:

ML.GET_INSIGHTS(
  MODEL `PROJECT_ID.DATASET.MODEL_NAME`
)
Output Schema
ColumnDescription
contributorsThe dimension values for a given segment (e.g., ['dim1=val1', 'dim2=val2']).
metric_testA numeric value that contains the sum of the value of the metric column in the test dataset for the given segment.
metric_controlA numeric value that contains the sum of the value of the metric column in the control dataset for the given segment.
differenceA numeric value that contains the difference between the metric_test and metric_control values: metric_test - metric_control.
relative_differenceA numeric value that contains the relative change in the segment value between the test and control datasets.
unexpected_differenceA numeric value that contains the unexpected difference between the segment's actual metric_test value and the segment's expected metric_test value, which is determined by comparing the ratio of change for this segment against the complement ratio of change.
relative_unexpected_differenceA numeric value that contains the ratio between the unexpected_difference value and the expected_metric_test value.
apriori_supportThe proportion of the total metric in the test and control sets that this segment represents.
contributionA numeric value that contains the absolute value of the difference value.

Example: Analyzing Revenue Change

-- 1. Create the model
CREATE OR REPLACE MODEL `my_project.my_dataset.revenue_analysis`
OPTIONS (
  MODEL_TYPE = 'CONTRIBUTION_ANALYSIS',
  is_test_col = 'is_current_year',
  dimension_id_cols = ['region', 'product_category', 'customer_segment'],
  contribution_metric = 'SUM(revenue)'
) AS
SELECT
  region,
  product_category,
  customer_segment,
  revenue,
  IF(date >= '2024-01-01', TRUE, FALSE) AS is_current_year
FROM
  `my_project.my_dataset.sales_data`;

-- 2. Get insights
SELECT
  *
FROM
  ML.GET_INSIGHTS(MODEL `my_project.my_dataset.revenue_analysis`)
ORDER BY
  unexpected_difference DESC;

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
Google
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