Saltar al contenido
Skillpedia
APIs y servidores (backend)22 mil · #10231

bigquery-udfs

Qué hace

Esta skill te ayuda a escribir funciones personalizadas para BigQuery cuando las funciones integradas no bastan. Es para desarrolladores que necesitan lógica especial o llamadas a servicios externos dentro de las consultas.

Cuándo usarla

  • ✓Cuando quieres escribir una función personalizada para BigQuery en SQL, JavaScript o Python.
  • ✓Cuando una función de Python o JavaScript en BigQuery necesita un paquete de PyPI o una biblioteca de Cloud Storage.
  • ✓Cuando quieres que una consulta de BigQuery llame a una API externa o a un servicio de Cloud Run mediante una función remota.

Link de la skill

https://github.com/google/skills/blob/main/skills/cloud/bigquery-udfs/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/google/skills/blob/main/skills/cloud/bigquery-udfs/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Escribe una función de BigQuery que llame a una API externa por cada fila y devuelva el resultado.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Elige el tipo de función más ligero que encaje con el trabajo y después la escribe y la despliega. También ayuda a resolver problemas cuando la función falla.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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):

  1. Install and Authenticate Google Cloud SDK: Install the Google Cloud SDK and authenticate:

    gcloud auth login
    

    Pass --project={project_id} and --region={region} (or --location for bq) explicitly on each command instead of running gcloud config set, which persists beyond the task. Default to us-central1 when the user has not specified a region (see BigQuery Locations).

  2. 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 (and run.googleapis.com for Remote Functions)
    CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:bigquery-udfs)" \
    gcloud services enable bigquery.googleapis.com \
      bigqueryconne
    
Preguntas frecuentes

¿Qué tipo de función debo elegir?

Las funciones SQL son la opción predeterminada porque son las más rápidas. Las opciones externas sirven cuando SQL no basta.

¿Puede una función de Python llamar a las APIs de Google Cloud?

Sí. Una función de Python puede llamar a APIs de Google Cloud y externas cuando usa una conexión.

¿Qué es una función remota?

Es una función que se ejecuta en tu propio endpoint de Cloud Run o de Cloud Run functions, y a la que llama BigQuery.

Detalles

Descripción original del autor

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

Popularidad

Estrellas en GitHub
22 mil
Posición en el ranking
#10231
Licencia
Apache-2.0
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas