본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)22k · #10231

bigquery-udfs

하는 일

이 스킬은 기본 함수로 부족할 때 BigQuery용 사용자 정의 함수를 작성하도록 돕습니다. 쿼리 안에서 특별한 로직이나 외부 서비스 호출이 필요한 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓SQL, JavaScript 또는 Python으로 BigQuery 사용자 정의 함수를 작성하고 싶을 때.
  • ✓BigQuery의 Python 또는 JavaScript 함수에 PyPI 패키지나 Cloud Storage 라이브러리가 필요할 때.
  • ✓BigQuery 쿼리가 원격 함수를 통해 외부 API나 Cloud Run 서비스를 호출하게 하고 싶을 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/google/skills/blob/main/skills/cloud/bigquery-udfs/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“각 행마다 외부 API를 호출하고 결과를 돌려주는 BigQuery 함수를 작성해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

작업에 맞는 가장 가벼운 함수 유형을 고른 다음 함수를 작성하고 배포합니다. 함수가 실패하면 문제 해결도 도와줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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
    
자주 묻는 질문

어떤 종류의 함수를 골라야 하나요?

SQL 함수가 가장 빠르므로 기본으로 쓰는 것이 좋습니다. 외부 옵션은 SQL로 충분하지 않을 때 씁니다.

Python 함수가 Google Cloud API를 호출할 수 있나요?

네. 연결(connection)을 사용하면 Python 함수가 Google Cloud와 외부 API를 호출할 수 있습니다.

원격 함수란 무엇인가요?

Cloud Run 또는 Cloud Run functions에서 자신의 엔드포인트로 실행되며, BigQuery가 호출하는 함수입니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
22k
순위
#10231
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬