Skip to main content

Function properties

💡Did you know...
Available from dbt v1.11 or with the dbt "Latest" release track.

Function properties can be declared in .yml files under a functions key.

We recommend that you put them in the functions/ directory. You can name these files schema.yml or whatever_you_want.yml, and nest them in subfolders within that directory.

functions/<filename>.yml

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

Example​

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

Was this page helpful?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

0
Loading