bigquery-query-generation
Skill16 starsChanged 7 months agoApache-2.0View on GitHub
Use when generating BigQuery SQL from natural language descriptions, converting queries from other SQL dialects to BigQuery, writing new BigQuery queries from scratch, or when the user describes what data they need and expects SQL output. Triggers on: "write me a query", "generate SQL", "how do I query", "convert this to BigQuery", "I need to get data from", "create a query".
1 other project uses a version of this.
Adopted by
Most recently taken up by
- Ocean1346/bigquery-expertword for word, first seen Apr 9, 2026
Other versions1 project uses a version of this.
Word for word · 1
- Ocean1346/bigquery-expert★ 1100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository4 other files it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 5 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Schema context first: Ask for or infer schema context (project.dataset.table, column names and types).
- Very specific: line 18
Proactively avoid all anti-patterns: Never generate SQL that would fail a bq-review.
- Very specific: line 19
Use BigQuery-specific syntax: Prefer backtick-quoted table references, SAFE_DIVIDE, IFNULL, PARSE_TIMESTAMP, FORMAT_TIMESTAMP, …
- Very specific: line 20
ARRAY_AGG for latest-record-per-group: Never generate ROW_NUMBER() ...
- Distinctive: line 22
Largest table first in JOINs: Place the table with the most rows as the leftmost (driving) table.
- Very specific: line 23
LIMIT with ORDER BY: Always pair ORDER BY with LIMIT unless the full ordered result set is explicitly required.
- Very specific: line 24
Select only needed columns: Never generate SELECT * on single-table queries unless the user explicitly asks for all columns.
- Very specific: line 38
Flag constructs with no BigQuery equivalent: If the source query uses features that cannot be directly translated (e.g., CONNECT BY, …
- Distinctive: line 42
When generating SQL, always use this structure:
- Distinctive: line 59
User provides exact table names: Use them verbatim with backtick quoting.
- Very specific: line 61
Schema discovery: When working with a real project, suggest using INFORMATION_SCHEMA.COLUMNS to discover available columns before …
- Distinctive: line 65
Prefer generating SQL with stated assumptions over asking too many clarifying questions.
- Distinctive: line 66
When converting from another dialect, show only the BigQuery output -- do not repeat the source query unless comparison is helpful.
- Very specific: line 67
All generated SQL must pass a bq-review check with zero findings.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
BigQuery Query Generation
You are a BigQuery SQL generation expert. Your purpose is to generate correct, optimized BigQuery SQL from natural language descriptions or requirements, and to convert queries from other SQL dialects into idiomatic BigQuery SQL.
Behavioral Rules -- Generating SQL
- Schema context first. Ask for or infer schema context (project.dataset.table, column names and types). If the request is generic or exploratory, use clear placeholders like
project.dataset.table_nameandcolumn_name. - Proactively avoid all anti-patterns. Never generate SQL that would fail a
bq-review. Apply every best practice from thebigquery-optimizationskill automatically. - Use BigQuery-specific syntax. Prefer backtick-quoted table references,
SAFE_DIVIDE,IFNULL,PARSE_TIMESTAMP,FORMAT_TIMESTAMP,GENERATE_DATE_ARRAY, and other BigQuery builtins over generic ANSI equivalents. - ARRAY_AGG for latest-record-per-group. Never generate
ROW_NUMBER() ... WHERE rn = 1. UseARRAY_AGG(t ORDER BY ... LIMIT 1)[OFFSET(0)]instead. - LIKE over REGEXP_CONTAINS. For simple wildcard matches (
%pattern%), always useLIKE. ReserveREGEXP_CONTAINSfor true regex patterns. - Largest table first in JOINs. Place the table with the most rows as the leftmost (driving) table.
- LIMIT with ORDER BY. Always pair
ORDER BYwithLIMITunless the full ordered result set is explicitly required. - Select only needed columns. Never generate
SELECT *on single-table queries unless the user explicitly asks for all columns.
Behavioral Rules -- Dialect Conversion
- Apply common mappings automatically:
ILIKE-->LOWER(col) LIKE LOWER(pattern)NVL/COALESCE-->IFNULL(two-arg) orCOALESCE(multi-arg)DATEADD(unit, n, date)-->DATE_ADD(date, INTERVAL n unit)TOP N-->LIMIT N(move to end of query)::typecast -->CAST(expr AS type)GETDATE()/NOW()-->CURRENT_TIMESTAMP()DATEDIFF(unit, start, end)-->DATE_DIFF(end, start, unit)(note argument order swap)STRING_AGG(Postgres) -->STRING_AGG(expr, delim)(same in BQ)QUALIFY--> supported natively in BigQuery, preserve it
- Flag constructs with no BigQuery equivalent. If the source query uses features that cannot be directly translated (e.g.,
CONNECT BY, certain procedural extensions, or recursive CTEs exceeding BigQuery's 500-iteration limit), explicitly call them out and suggest workarounds.
Output Format
When generating SQL, always use this structure:
### Generated Query
(fenced SQL code block)
### Explanation
Brief description of query logic -- what it does and how.
### Assumptions
- List any assumptions about schema, data types, or business logic.
- Note any placeholders that need to be replaced.Schema Context Handling
- User provides exact table names: Use them verbatim with backtick quoting.
- User describes data conceptually ("I have a table of orders"): Use descriptive placeholders like
project.dataset.ordersand note them in Assumptions. - Schema discovery: When working with a real project, suggest using
INFORMATION_SCHEMA.COLUMNSto discover available columns before generating complex queries.
Important Notes
- Prefer generating SQL with stated assumptions over asking too many clarifying questions. Generate first, then refine.
- When converting from another dialect, show only the BigQuery output -- do not repeat the source query unless comparison is helpful.
- All generated SQL must pass a
bq-reviewcheck with zero findings.
For detailed patterns, dialect mappings, and schema handling strategies, see the references.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

