本文へ移動
cccskills
無料GitHub で公開日本語紹介

bigquery

指標の定義やテーブルの列名を確認してからBigQueryを検索し、期間や費用に配慮したSQLでデータを集計するスキルです。

原文原文の説明を見る

Query the BigQuery warehouse. Use for warehouse SQL, BigQuery tables, Amplitude-in-BigQuery events, or a metric the data dictionary says lives in BigQuery.

BuilderIO/agent-nativeスター 7,526(GitHub 7,526 + cccskills 0)
連携ツールGoogle Cloud

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • BigQueryにある指標を集計したいとき
  • イベントデータの期間別推移を見たいとき
  • クエリ前にテーブル構成や費用を確認したいとき

日本語での紹介

できること

BigQuery上のテーブルを調べ、SQLでデータを集計するための手順を扱います。SQLを書く前に find-data で指標の定義や保存済みクエリを探し、search-bigquery-schema でデータセット、テーブル、列名を確認します。業務データではdbtで整備されたテーブルを優先し、イベントやページビューなど大きなテーブルには日付範囲を指定します。大規模なクエリの実行前には estimate-query-cost で読み取り量と費用を見積もり、実データを使って結果を確認します。

こんなときに便利

指標がBigQueryにあるとデータ辞書で分かっているときや、AmplitudeのイベントをBigQueryに複製したデータから調べたいときに向いています。列名やデータ型の違いによる誤集計を避けたい場合、既存の定義やテーブル構成を確認してからクエリを組み立てられます。指標がdbt Semantic Layerで定義されている場合は、そちらの手順を先に確認します。

使い方の例

  • 「この指標の定義とBigQueryの保存先を調べて」
  • 「直近30日間のイベント数を集計して、実行費用も見積もって」

注意点

利用にはBigQueryへの接続設定や権限が必要です。大きなクエリでは実行前に費用を確認し、見積もりが実行あたり1ドルまたは月あたり50ドルを超える場合は金額を伝える手順です。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(1)

  • SKILL.md10.5 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

BigQuery

CRITICAL: BigQuery is a Native Agent Tool

bigquery is available directly in the agent's tool list as a native callable tool.

  • If you see bigquery in your available tools — call it directly with your SQL. Do not use HTTP workarounds, web-request hacks, or scripts as a substitute.
  • The server/lib/bigquery.ts description below is the underlying implementation. It does not mean BigQuery is only accessible via terminal commands or scripts.
  • When uncertain if the tool works, call it — don't reason your way to "it won't work". Empirically test by calling the tool.

Data-Dictionary-First Discipline

Before writing any SQL, verify the metric definition and exact table/column names.

  1. Call find-data with the user’s metric or entity question first; it ranks dictionary definitions, saved SQL examples, and generated source metadata together.
  2. Use search-bigquery-schema to confirm exact dataset, table, and column names.
  3. Only write SQL after you know the correct table and columns. Do not guess.

Why this matters: column names commonly differ from spec (see "Column Name Differences" below). Querying the wrong column returns wrong numbers silently. Confirming with search-bigquery-schema or INFORMATION_SCHEMA.COLUMNS before writing the query is always faster than debugging a wrong result.

Source Of Truth Order

Before writing SQL, use the highest-confidence source available:

  1. Owner-defined dbt metric question, even unnamed: follow the dbt path in data-querying/SKILL.md, including its status rules, retry, and warehouse conditions. Its definition outranks any table. Only a successful get-dbt-connection result with readiness: "not_connected" and an empty connections[] permits normal source selection. If any row is ready, keep dbt as the source even when top-level readiness is null. If rows exist but none is ready, report or resolve their readiness and stop. Treat connected: false, null readiness, and failed or unreadable lookups as unknown, not disconnected. A warehouse figure for this metric needs an explicit user request.
  2. find-data with a focused metric or entity question.
  3. Existing dashboard SQL or saved analyses that already answer the same metric.
  4. search-bigquery-schema metadata for exact datasets, tables, and columns.
  5. A concise user clarification when the business meaning cannot be inferred.

Do not invent dataset, table, or column names. BigQuery is a warehouse, not one table; BIGQUERY_PROJECT_ID is only the default project.

Warehouse Table Priority (CRITICAL)

Always prefer dbt-built warehouse tables before raw source tables. They are warehouse data, not owner-approved Semantic Layer definitions; for an owner-defined metric, use the dbt step (step 0 of the source order) first.

  1. dbt_mart.* — dbt-built, first choice for business-level data (deals, contracts, subscriptions, customers, companies).
  2. dbt_analytics.* — dbt-built, first choice for reporting views and aggregated metrics.
  3. dbt_staging_bigquery.* — for raw staged data (pageviews, signups) when dbt_mart/analytics don't have it.
  4. dbt_intermediate.* — for joins/transforms when no mart or analytics table exists.
  5. analytics.* / amplitude.* / raw tables — last resort only, when no dbt equivalent exists.

Never query raw source tables if a dbt model covers the same data. dbt models are deduplicated, tested, and have canonical column names. Raw tables may have duplicates, schema drift, and inconsistent naming.

Avoid dbt_dev.* — development schema, excluded globally.

Always Bound Queries by Date

Always include a date or timestamp filter in any query that touches large event or pageview tables. Unbounded queries scan full table history, hit byte limits, and return unusable result sets. Use the most restrictive date range that still answers the question.

-- Always add: WHERE event_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
-- Or for TIMESTAMP columns: WHERE event_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)

For account health, verify the reporting period, as-of field, and freshness. Never label a current partial-month snapshot as last month's completed usage.

Actions

ActionUse
data-source-status --key bigqueryCheck whether BigQuery credentials and project are configured.
find-data --question <topic>Find ranked metric definitions and saved query examples before SQL.
search-bigquery-schemaList datasets, list tables in a dataset, or describe table columns.
estimate-query-cost --sql "<sql>"Free dry run: bytes, $ per run, and $ per month for scheduled runs.
bigquery --sql "<sql>"Run a real warehouse query after table/column names are known.
query-dbt-semantic-metric --metricName <exact dbt name>Run an owner-defined dbt Semantic Layer metric before warehouse SQL.
get-dbt-connectionCheck each connections[].readiness and its missing setup step.

Check Cost Before Big Queries

Before running a query over a large event or pageview table, call estimate-query-cost with the same SQL. It dry-runs the query (BigQuery reads and bills nothing) and prices it at on-demand rates. Pass runsPerMonth for anything scheduled, such as 8640 for an alert that polls every 5 minutes. Estimates over $1 per run or $50 per month are flagged: tell the user the number before going ahead.

For direct Amplitude/PostHog/Mixpanel product-event data (outside the warehouse copy), there is no first-class action — call provider-api-catalog / provider-api-docs then provider-api-request (provider amplitude, posthog, or mixpanel), and aggregate in run-code for corpus-wide event analysis.

Schema Discovery

Use search-bigquery-schema instead of asking the user to manually print field lists:

pnpm action search-bigquery-schema
pnpm action search-bigquery-schema --dataset=product_events
pnpm action search-bigquery-schema --table=product_events.events
pnpm action search-bigquery-schema --dataset=product_events --search=rootOrganizationId

When describing a table, copy exact field names from the action result. If a field has a nested path such as event_properties.rootOrganizationId, use the proper BigQuery JSON or STRUCT access pattern for that field type.

Dictionary Trust

Approved dictionary entries are canonical. Human-authored but unreviewed entries are usable with light verification. AI-generated unapproved entries are suggestions only: verify the table and columns with search-bigquery-schema and prefer saving a reviewed dictionary update once the meaning is clear.

Common Patterns

  • Use @project.dataset.table when you want the configured project placeholder.
  • Use @app_events only for the optional app-events table; it is not the whole warehouse and it is not a connection-status signal.
  • For metrics or dashboard panels, run at least one real data query before presenting numbers.
  • An unknown table or column error is a normal, recoverable signal — not a stopping point. Use search-bigquery-schema (or INFORMATION_SCHEMA) to get the exact datasets, tables, and columns, correct the query based on the error, and run it again. Iterate until it succeeds or you have made a few corrective attempts; only surface to the user if it still fails or the error is non-recoverable (missing credentials, permission, quota).

Column Name Differences (Common Bug Sources)

Spec ColumnActual ColumnTable
first_pageview_datecreated_date (TIMESTAMP)first_pageviews
channel (pageviews)first_touch_channelall_pageviews
referrerc_referrerall_pageviews
referrer_channelsession_channelall_pageviews
user_create_dateuser_create_dproduct_signups
deal_stagestage_namedim_deals
deal_amountamountdim_deals

Always verify with search-bigquery-schema before writing SQL against an unfamiliar table.

Join Paths — Identity Stitching Rule

Always match on BOTH a stable id AND email when joining contacts/users across tables:

-- CORRECT: both user_id and email
ON signups.user_id = contacts.user_id
AND LOWER(signups.email) = LOWER(contacts.email)

-- WRONG: id alone — IDs can be reassigned or recycled
ON signups.user_id = contacts.user_id

IDs can be reassigned after deletes/merges. Email alone over-matches shared addresses. Require both for exact matches; flag email-only or id-only joins as low-confidence caveats.

SQL Patterns

Timestamps vs Dates

  • TIMESTAMP columns need TIMESTAMP('2025-11-01') comparisons, not date strings.
  • DATE columns need DATE('2025-11-01').
  • Use DATE(timestamp_col) before DATE_TRUNC to avoid type mismatch errors.
  • Use QUALIFY ROW_NUMBER() OVER (PARTITION BY id ORDER BY updated_at DESC) = 1 for deduplication — cleaner than a subquery. Put the partition-date filter in the same WHERE: a dedupe over a whole table, or a view that dedupes before your filter, scans every partition. For first-party events, read first_party_analytics_events_raw_query_range(start_date, end_date), not the first_party_analytics_events_raw_query view. It leaves out http.response, which holds most of the properties bytes; read that event from the raw table with a narrow date range and an event_name filter.

Type Casting

  • Some warehouse tables store booleans as STRING 'true'/'false' — always CAST(col AS STRING) = 'true' rather than treating as BOOL.
  • Amount/ARR fields may be stored as STRING — CAST(amount AS FLOAT64) before arithmetic.

Avoid Double WHERE

-- WRONG: syntax error
WHERE date BETWEEN '...' AND '...'
WHERE col IS NOT NULL

-- CORRECT: single WHERE with AND
WHERE col IS NOT NULL AND date BETWEEN '...' AND '...'

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

a2a-assets

無料概要あり

複数のアプリやMCPホストからブランド画像・動画を生成、調整、書き出し、挿入する作業を支援します。ライブラリ選択や修正依頼も扱います。

  • スライド用のブランド画像を作りたいとき
  • 既存素材をフィードバックに合わせて直したいとき
  • 動画素材を生成して書き出したいとき
BuilderIO/agent-native7,5262026年10月26日 更新

account-health

無料概要あり

特定の顧客企業について、契約と製品利用の数値を照らし合わせ、根拠や不足情報を明記した健全性レポートをまとめます。

  • 顧客の健全性を確認したいとき
  • 契約席数と実利用を比べたいとき
  • 更新前に利用状況を整理したいとき
BuilderIO/agent-native7,5262026年10月26日 更新

actions

無料概要あり

アプリの操作をエージェントと画面の両方から呼び出せるアクションとして実装し、API連携や画面のデータ取得を一貫した形で追加するスキルです。

  • 新しいアプリ操作を追加したいとき
  • 外部APIと連携したいとき
  • 画面からデータを取得したいとき
BuilderIO/agent-native7,5262026年10月26日 更新

adding-a-feature

無料概要あり

新機能をUI・エージェント用アクション・説明資料・画面状態の4領域でそろえ、利用者とエージェントのどちらからも一貫して使えるようにするチェックリストです。

  • 新機能追加の作業範囲を整理したいとき
  • UIとエージェント操作をそろえたいとき
  • 画面状態の同期漏れを防ぎたいとき
BuilderIO/agent-native7,5262026年10月26日 更新

adhoc-analysis

無料概要あり

複数のデータソースを照合して、傾向や指標、根拠をまとめた分析結果を作成します。必要に応じて、再実行できるダッシュボードとして保存できます。

  • 商談と通話記録を照合したいとき
  • 顧客の利用状況を横断して調べたいとき
  • 繰り返し更新できる分析を保存したいとき
BuilderIO/agent-native7,5262026年10月26日 更新

admin-surfaces

無料概要あり

Analyticsの管理画面で、機能フラグの状態確認と切り替え、ダッシュボード利用状況の調査、接続先アプリのデータベース管理を行います。

  • アプリごとの機能フラグを確認・変更したいとき
  • ダッシュボードの所有者や利用状況を調べたいとき
  • 接続済みアプリのテーブルを管理したいとき
BuilderIO/agent-native7,5262026年10月26日 更新

BuilderIO のスキルをすべて見る

このスキルの問題を報告する