type
💡Did you know...
Available from dbt v1.11 or with the dbt "Latest" release track.
functions/<filename>.yml
functions:
  - name: <function name>
    type: scalar | aggregate | table  # aggregate and table coming soon
Definition
The type property specifies the type of user-defined function (UDF) you're creating. This property is optional and defaults to scalar if not specified.
Supported function types
scalar (default)
A scalar function returns a single value for each row of input. This is the most common type of UDF.
Example use cases:
- Data validation (checking if a string matches a pattern)
- Data transformation (converting formats, cleaning strings)
- Custom calculations (complex mathematical operations)
functions/schema.yml
functions:
  - name: is_positive_int
    description: Determines if a string represents a positive integer
    type: scalar
    arguments:
      - name: input_string
        data_type: STRING
    returns:
      data_type: BOOLEAN
aggregate
Aggregate functions operate on multiple rows and return a single value. These functions are used in GROUP BY operations.
Coming soon
Support for aggregate functions is planned for a future release.
Example:
functions/schema.yml
functions:
  - name: double_total
    description: Sums values and doubles the result
    type: aggregate
    arguments:
      - name: values
        data_type: FLOAT
        description: A sequence of numbers to aggregate
    returns:
      data_type: FLOAT
table
Table functions return a table (multiple rows and columns) rather than a single value.
Coming soon
Support for table functions is planned for a future release.
Related documentation
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
0