Bigquery

by sourcegraph

tooldata

Instructions for querying Google BigQuery using the bq command-line tool. Useful for running SQL queries, exploring datasets, and exporting results.

Skill Details

Repository Files

1 file in this skill directory


name: bigquery description: Instructions for querying Google BigQuery using the bq command-line tool. Useful for running SQL queries, exploring datasets, and exporting results.

BigQuery Skill

This skill enables you to query Google BigQuery using the bq command-line tool.

Authentication is already configured. The default project is project_id.

Use the project_id_exploration dataset as scratch space for temporary tables and experimentation.

The public dataset contains tables synced from the production Postgres database.

1. Explore Available Datasets

List datasets in the current project (defaults to project_id):

bq ls

List datasets in a specific project:

bq ls --project_id=PROJECT_ID

List tables in a dataset:

bq ls PROJECT_ID:DATASET_NAME

Get table schema:

bq show --schema --format=prettyjson PROJECT_ID:DATASET_NAME.TABLE_NAME

2. Run Queries

Run a simple query:

bq query --use_legacy_sql=false 'SELECT * FROM `project.dataset.table` LIMIT 10'

Run a query with formatted output:

bq query --use_legacy_sql=false --format=prettyjson 'YOUR_QUERY'

Run a query and save to a destination table:

bq query --use_legacy_sql=false --destination_table=PROJECT:DATASET.NEW_TABLE 'YOUR_QUERY'

Run a dry run to estimate costs:

bq query --use_legacy_sql=false --dry_run 'YOUR_QUERY'

3. Export Results

Export to CSV:

bq query --use_legacy_sql=false --format=csv 'YOUR_QUERY' > results.csv

4. Best Practices

  • Always use --use_legacy_sql=false for standard SQL syntax
  • Use LIMIT clauses when exploring data to reduce costs
  • Use --dry_run to estimate query costs before running expensive queries
  • Use backticks around table references: `project.dataset.table`

5. Common Patterns

Preview table data:

bq head -n 10 PROJECT:DATASET.TABLE

Get table info (row count, size):

bq show --format=prettyjson PROJECT:DATASET.TABLE

Query with parameters:

bq query --use_legacy_sql=false --parameter='name:STRING:value' 'SELECT * FROM `table` WHERE col = @name'

Related Skills

Xlsx

Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas

data

Clickhouse Io

ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

datacli

Clickhouse Io

ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

datacli

Analyzing Financial Statements

This skill calculates key financial ratios and metrics from financial statement data for investment analysis

data

Data Storytelling

Transform data into compelling narratives using visualization, context, and persuasive structure. Use when presenting analytics to stakeholders, creating data reports, or building executive presentations.

data

Kpi Dashboard Design

Design effective KPI dashboards with metrics selection, visualization best practices, and real-time monitoring patterns. Use when building business dashboards, selecting metrics, or designing data visualization layouts.

designdata

Dbt Transformation Patterns

Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.

testingdocumenttool

Sql Optimization Patterns

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

designdata

Anndata

This skill should be used when working with annotated data matrices in Python, particularly for single-cell genomics analysis, managing experimental measurements with metadata, or handling large-scale biological datasets. Use when tasks involve AnnData objects, h5ad files, single-cell RNA-seq data, or integration with scanpy/scverse tools.

arttooldata

Xlsx

Spreadsheet toolkit (.xlsx/.csv). Create/edit with formulas/formatting, analyze data, visualization, recalculate formulas, for spreadsheet processing and analysis.

tooldata

Skill Information

Category:Technical
Last Updated:12/11/2025