entry_point
entry_point
entry_point는 Python UDF를 만들 때 호출할 Python 함수를 지정하는 설정이에요. Python UDF는 현재 Snowflake, BigQuery, Databricks에서 지원되며, 각 웨어하우스마다 엔트리 포인트 함수를 부르는 이름이 달라요.
출처: 문서
본문
functions:
- name: <function name>
config:
entry_point: <string> # required for Snowflake and BigQuery; optional and ignored on Databricks
정의 (Definition)
Python UDF를 만들 때 entry_point에서 호출할 Python 함수를 지정해요. Python UDF는 현재 Snowflake, BigQuery, Databricks에서 지원되며, 각 웨어하우스마다 엔트리 포인트 함수를 부르는 이름이 달라요.
예시 (Example)
functions/my_function.py에 엔트리 포인트로 main 함수를 사용하는 다음과 같은 Python UDF가 있다고 해 볼게요:
import re
def _digits_only(s: str) -> bool:
return bool(re.search(r'^[0-9]+$', s or ''))
def _to_flag(is_match: bool) -> int:
return 1 if is_match else 0
def main(a_string: str) -> int:
"""
This is used as the entry point for the UDF.
Returns 1 if a_string represents a positive integer (e.g., "10"),
else 0.
"""
return _to_flag(_digits_only(a_string))
UDF를 정의한 후 YAML 파일에서 main을 entry_point로 지정할 수 있어요. entry_point: main은 main 함수를 UDF의 엔트리 포인트로 가리키고, _digits_only와 _to_flag는 헬퍼 함수예요.
functions:
- name: is_positive_int
description: Returns 1 if a_string matches ^[0-9]+$, else 0
config:
runtime_version: "3.11" # required
entry_point: main # required: points to the function above
arguments:
- name: a_string
data_type: string
returns:
data_type: integer
관련 문서 (Related documentation)
- 사용자 정의 함수 (User-defined functions)
- 함수 properties
- 함수 설정 (Function configurations)
- type
- volatility
- runtime_version
- packages
- arguments
- returns
더 알아보기 (Learn more)
- 사용자 정의 함수 — dbt에서 Python UDF 만들기
- runtime_version — Python 런타임 버전 지정