bigquery-udfs
What it does
This skill helps you write custom functions for BigQuery when built-in functions are not enough. It is for developers who need special logic or calls to outside services inside queries.
When to use it
- ✓When you want to write a custom function for BigQuery in SQL, JavaScript or Python.
- ✓When a Python or JavaScript function in BigQuery needs a PyPI package or a Cloud Storage library.
- ✓When you want a BigQuery query to call an outside API or a Cloud Run service through a remote function.
Skill link
https://github.com/google/skills/blob/main/skills/cloud/bigquery-udfs/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Write a BigQuery function that calls an external API for each row and returns the result.”
5 new skills a week. 1 minute to read.
How it works
It chooses the lightest function type that fits the job, then writes and deploys the function. It also helps troubleshoot the function when it fails.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
BigQuery User-Defined Functions (UDFs)
BigQuery User-Defined Functions (UDFs) extend GoogleSQL with custom logic
written in SQL, JavaScript, managed Python (python-3.11), or hosted externally
as Remote Functions on Cloud Run and Cloud Run functions.
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read and follow the instructions in
Usage Attribution.
Choosing the Right UDF Type
Always select the lightest-weight runtime that satisfies the requirement, because BigQuery optimizes native SQL expressions inline while external runtimes incur serialization and container startup overhead:
| UDF Type | Connection Required? | When to Use | Key Constraints |
|---|---|---|---|
| SQL UDF (Default) | No | Composable expressions, regex, struct/array manipulation, aggregate functions (CREATE AGGREGATE FUNCTION), or polymorphic ANY TYPE parameters. |
Lowest latency; zero external dependencies; supports TEMP or persistent functions. |
| JavaScript UDF | No | Custom string/JSON logic or bundling .js libraries from Cloud Storage (gs://). |
Runs in V8 sandbox; INT64 unsupported as input (pass as FLOAT64 or STRING). Max 32 KB inline code, 1 MB per external resource. Supports TEMP or persistent functions. |
| Managed Python UDF (Offline) | No | Pure compute using Python 3.11, PyPI wheels (packages=[...]), Cloud Storage .py modules (library=[...]), or vectorized Pandas/PyArrow batches. |
Persistent functions only (CREATE TEMP FUNCTION unsupported). Outbound network blocked. Max container size: 4 vCPU / 16 GiB. JSON, RANGE, INTERVAL, GEOGRAPHY unsupported. |
Managed Python UDF (WITH CONNECTION) |
Yes (CLOUD_RESOURCE) |
Invoking Google Cloud APIs (e.g., Cloud Translation, Gemini Enterprise Agent Platform) or online HTTP endpoints directly from Python inside BigQuery containers. | Requires WITH CONNECTION. Outbound traffic restricted to restricted.googleapis.com in VPC-SC perimeters (VPC networks unsupported). Max container size: 4 vCPU / 16 GiB. |
Remote Function (REMOTE WITH CONNECTION) |
Yes (CLOUD_RESOURCE) |
Calling external APIs or microservices when you need non-Python runtimes (Go, Java, Node.js), private VPC network access, GPUs, or custom Cloud Run scaling. | Requires Cloud Run HTTPS endpoint implementing BigQuery JSON batch contract and roles/run.invoker. Max input 5 MB per row; response limit 15 MB (Cloud Run) / 10 MB (1st gen). |
Prerequisites & Setup
Ensure the Google Cloud project has an active billing account attached (see BigQuery Pricing):
Install and Authenticate Google Cloud SDK: Install the Google Cloud SDK and authenticate:
gcloud auth loginPass
--project={project_id}and--region={region}(or--locationforbq) explicitly on each command instead of runninggcloud config set, which persists beyond the task. Default tous-central1when the user has not specified a region (see BigQuery Locations).Enable Required APIs:
- For SQL, JavaScript, and offline Python UDFs:
bigquery.googleapis.com - Additionally for Python UDFs calling APIs (
WITH CONNECTION) and Remote Functions:bigqueryconnection.googleapis.com(andrun.googleapis.comfor Remote Functions)
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-udfs)" \ gcloud services enable bigquery.googleapis.com \ bigqueryconne- For SQL, JavaScript, and offline Python UDFs:
FAQ
Which kind of function should I pick?
SQL functions are the default because they run fastest. External options are for when SQL is not enough.
Can a Python function call Google Cloud APIs?
Yes. A Python function can call Google Cloud and external APIs when it uses a connection.
What is a remote function?
It is a function that runs on your own endpoint in Cloud Run or Cloud Run functions, which BigQuery calls.
Details
Original description by the author
Creates, deploys, and troubleshoots BigQuery User-Defined Functions (UDFs) and Remote Functions across SQL, JavaScript, Python, and Cloud Run endpoints. Use when writing custom scalar or aggregate functions in BigQuery, installing PyPI packages or Cloud Storage libraries in a Python or JavaScript UDF, or calling Google Cloud and external APIs from a Python UDF (WITH CONNECTION) or Remote Function. Don't use for standard BigQuery table/dataset CRUD (use bigquery-basics), DataFrames client workflows (use bigquery-bigframes), or BigQuery ML models (use bigquery-ai-ml).
repo: google/skills
Popularity
- GitHub stars
- 22k
- Ranking position
- #10231
- License
- Apache-2.0
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
finding-google-skills
22kHelps your agent find the right Google guides for a setup task, such as hosting, databases, storage, sign-in or AI model serving.
gcloud
22kHelps your agent write and check Google Cloud gcloud commands, looking up exact syntax before it runs anything so it does not guess flags.
google-cloud-recipe-auth
22kGuides your agent through Google Cloud identity and access, including how people and services sign in and which permissions they get.
google-cloud-recipe-onboarding
22kWalks a new developer through first steps on Google Cloud, including choosing a project, linking billing, and deploying a first resource.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.