bq-augmented-analytics

Build and validate BigQuery Augmented Analytics TVF queries and Conversational Analytics Data Agents.

Updated Jul 7, 2026
One-click install
npx skills add https://github.com/ricardolui/gcp-custom-agent-skills --skill bq-augmented-analytics-ricardolui
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bq-augmented-analytics
Source: https://github.com/ricardolui/gcp-custom-agent-skills/tree/main/bq-augmented-analytics
Command: npx skills add https://github.com/ricardolui/gcp-custom-agent-skills --skill bq-augmented-analytics-ricardolui

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sqlglot, google-cloud-bigquery, and includes scripts (resource) components.

What problem does it solve? Writing correct GoogleSQL for BigQuery's Augmented Analytics TVFs (AI.CAUSAL_EFFECT, ML.CORRELATION, ML.DETECT_CHANGE_POINTS, ML.TREND, ML.SEASONALITY) requires exact named-argument syntax, correct namespace usage, and knowledge of output schemas, while provisioning Conversational Analytics Data Agents demands strict JSON payload and attribution rules that are easy to get wrong. ## Core Features & Use Cases - TVF Reference & Validation: Complete syntax, input requirements, and output schemas for all five Augmented Analytics TVFs, plus AST validation via sqlglot with required named-argument (=>) checks. - Dual-Mode Execution: Scripts probe GCP OAuth scopes and either execute live BigQuery queries with mandatory datacloud:jetski labels or fall back to offline dry-run validation under read-only scopes. - Conversational Analytics Agent Provisioning: Verified JSON payload patterns for Data Agents, including tableReferences grounding, dual published/staging contexts, and un-fenced golden queries covering each TVF. - Use Case: Measure the causal impact of an earnings announcement on a stock's close price by generating an AI.CAUSAL_EFFECT query, validating it offline, and executing it against BigQuery with proper attribution labels. ## Quick Start Ask the assistant to write and validate an AI.CAUSAL_EFFECT query measuring the impact of an event on your BigQuery time-series table, then run scripts/run_augmented_sql.py with your project ID to validate or execute it.

Frequently Asked Questions about bq-augmented-analytics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a causal impact analysis in BigQuery?

Use the AI.CAUSAL_EFFECT table-valued function with data_col, timestamp_col, and intervention_timestamp as named arguments. It trains an ARIMA_PLUS counterfactual baseline on pre-intervention data and returns p_value, prob_causal_effect, and absolute and relative effect columns.

What is the difference between AI.CAUSAL_EFFECT and ML.TREND in BigQuery?

AI.CAUSAL_EFFECT measures the causal impact of a specific intervention by comparing post-event actuals against a counterfactual forecast. ML.TREND extracts the long-term directional component of a time series using moving average smoothing, without modeling any intervention.

How do I validate BigQuery TVF syntax without executing the query?

Run scripts/run_augmented_sql.py with the --dry-run flag or under read-only OAuth scopes. It parses the query with sqlglot using the bigquery dialect, checks required named arguments for each TVF, and outputs a structured JSON validation report with exit code 0.

Why does my bq command fail with a --label flag error?

The --label flag is only supported on mutating bq commands like query, load, mk, update, cp, and extract. Passing it to read-only commands such as bq ls, bq show, or bq head causes a fatal flag positioning error, so omit it there.

Can Conversational Analytics Data Agents use property graph references?

propertyGraphReferences works on Enterprise slot reservations, but GRAPH_TABLE dry-run compilation fails with a 400 error on standard on-demand projects. For universal compatibility, ground Data Agents with datasourceReferences.bq.tableReferences instead.

What happens when GCP credentials have read-only scope?

The scripts detect cloud-platform.read-only scopes via the tokeninfo endpoint and switch to offline verification mode, performing AST and TVF signature validation without live execution. They exit cleanly with code 0 and print the gcloud auth login --update-adc remediation command.