함수 속성
함수 속성 (Function properties)
함수 속성은 .yml 파일의 functions 키 아래에 선언할 수 있어요. functions/ 디렉토리에 두는 걸 권장하며, 파일 이름은 schema.yml이나 whatever_you_want.yml처럼 지을 수 있고 해당 디렉토리의 하위 폴더에 중첩할 수 있어요.
출처: 문서
본문
💡
dbt v1.11부터 또는 dbt "v1 Latest" 릴리즈 트랙에서 사용할 수 있어요.
함수 속성은 .yml 파일의 functions 키 아래에 선언할 수 있어요.
functions/ 디렉토리에 두는 걸 권장해요. 파일 이름은 schema.yml이나 whatever_you_want.yml처럼 지을 수 있고, 해당 디렉토리의 하위 폴더에 중첩할 수 있어요.
functions/
functions:
- name: <string> # required
description: <markdown_string> # optional
config: # optional
<function_config>: <config_value>
type: scalar | aggregate # optional, defaults to scalar.
volatility: deterministic | stable | non-deterministic # optional
runtime_version: <string> # required for Python UDFs
entry_point: <string> # required for Python UDFs
packages: [<string>] # optional, Python UDFs only
docs:
show: true | false
node_color: <color_id> # Use name (such as node_color: purple) or hex code with quotes (such as node_color: "#cd7f32")
arguments: # optional
- name: <string> # required if arguments is specified
data_type: <string> # required if arguments is specified, warehouse-specific
description: <markdown_string> # optional
default_value: <string | boolean | integer> # optional, available in Snowflake and Postgres
- name: ... # declare additional arguments
returns: # required
data_type: <string> # required, warehouse-specific
description: <markdown_string> # optional
overloads: # optional, SQL UDFs (Snowflake and Postgres) and Python UDFs (Snowflake), available in v1.12+
- defined_in: <string> # required, name of the SQL or Python file containing this overload's body
arguments: # optional
- name: <string> # required if arguments is specified
data_type: <string> # required if arguments is specified, warehouse-specific
description: <markdown_string> # optional
default_value: <string | boolean | integer> # optional, available in Snowflake and Postgres
- name: ... # declare additional arguments
returns: # optional, inherits from root function if omitted
data_type: <string> # required if returns is specified, warehouse-specific
description: <markdown_string> # optional
- defined_in: ... # declare additional overloads
- name: ... # declare properties of additional functions
예시
functions/schema.yml
functions:
- name: is_positive_int
description: Determines if a string represents a positive (+) integer
config:
type: scalar
volatility: deterministic
database: analytics
schema: udf_schema
arguments:
- name: a_string
data_type: string
description: The string that I want to check if it's representing a positive integer (like "10")
returns:
data_type: boolean
description: Returns true if the input string represents a positive integer, false otherwise
overloads:
- defined_in: is_positive_int_numeric
arguments:
- name: a_num
data_type: numeric
description: The number that I want to check if it's a positive integer
returns:
data_type: boolean
더 알아보기 (Learn more)
- Function configurations — 함수 구성 방법
- Function arguments — 함수 인자 속성
- Overloads — 함수 오버로드