All skills
google avatar

/bigquery-ai-ml

@d6b9f75
by googlegoogle/skills21k stars
1,698

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, 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.

Use this Skill: https://skilld.dev/gh/google/skills/bigquery-ai-ml

This session only. Nothing lands on disk.

referencesai_generate_table.md

≈755 tokens on demand. Your agent reads this file only when SKILL.md points to it.

AI.GENERATE_TABLE

Uses Gemini models to extract information into a predefined SQL schema. It is a "Table-Valued Function," meaning it is called in the FROM clause.

Syntax

SELECT
  *
FROM
  AI.GENERATE_TABLE(
    MODEL `project.dataset.model`,
    { TABLE `project.dataset.table` | (QUERY_STATEMENT) },
  STRUCT(
    OUTPUT_SCHEMA AS output_schema
    [, MAX_OUTPUT_TOKENS AS max_output_tokens]
    [, TOP_P AS top_p]
    [, TEMPERATURE AS temperature]
    [, STOP_SEQUENCES AS stop_sequences]
    [, SAFETY_SETTINGS AS safety_settings]
    [, REQUEST_TYPE AS request_type])
  )

Input Arguments

Argument Requirement Type Description
model Required The remote model resource (e.g., project.dataset.model).
input_data Required The source table or SELECT statement. Must contain a column named or aliased as prompt.
output_schema Required String A STRUCT containing SQL-style column definitions (e.g., "name STRING, qty INT64").
max_output_tokens Optional Int64 [1, 8192]. Limits response length.
temperature Optional Float64 [0.0, 2.0]. Degree of randomness (0.0 is recommended for deterministic responses).
top_p Optional Float64 [0.0, 1.0]. Changes how the model selects tokens for output.
stop_sequences Optional Array<String> Strings that halt model generation if matched.
safety_settings Optional Array<Struct> Thresholds to filter hate speech, harassment, etc.
request_type Optional String SHARED, DEDICATED, or UNSPECIFIED (defaults to UNSPECIFIED).

Prompt Construction (STRUCT Fields)

When using a QUERY_STATEMENT, you can build multimodal prompts by combining types:

  • STRING / ARRAY<STRING>: Literal text or column names.
  • ObjectRefRuntime: Use OBJ.GET_ACCESS_URL(col, 'r') for images/PDFs.

Output Schema

The output table is a join of your source data and the model's generated content. It preserves all original input columns to maintain traceability.

Column Type Description
[Input Columns] (As Input) Every column included in your input TABLE or QUERY_STATEMENT.
[Schema Columns] (As Defined) The typed columns you specified in the OUTPUT_SCHEMA argument.
full_response JSON The raw, unparsed JSON response from the underlying Gemini model.
status STRING Execution status; will contain error messages if a row fails extraction.

Example: Preserving Keys During LLM Summarization

-- The output includes 'ticket_id' from the input and 'priority' and 'issue_summary' from the AI schema
SELECT
  ticket_id,
  priority,
  issue_summary
FROM AI.GENERATE_TABLE(
  MODEL `prod.models.gemini_flash`,
  (SELECT ticket_id, body AS prompt FROM `support.tickets`),
  STRUCT("priority STRING, issue_summary STRING" AS output_schema)
)

Source: SKILL.md on GitHub

No alerts9d3 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    This skill provides a comprehensive reference for BigQuery's built-in AI and machine learning functions. It includes a security consideration regarding potential indirect prompt injection when processing untrusted data with generative AI functions. These patterns are standard for the intended data analysis use cases and can be managed through proper prompt design and data validation.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

Signed by skilld at d6b9f75. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last week
metadata
{
  "version": "1.1.0",
  "category": "AiAndMachineLearning"
}

README badge

README badge for google/skills/bigquery-ai-ml