Skip to content

[UDFs] Ability to specify a function's volatility #12030

@QMalcolm

Description

@QMalcolm

Housekeeping

  • I am a maintainer of dbt-core

Short description

Data warehouses have a general concept of volatility when defining UDFs. Defining a function's volatility lets the data warehouse do some optimizations when executing the function.

  • Snowflake uses VOLATILE / IMMUTABLE (default is VOLATILE)[docs]
  • Redshift uses VOLATILE / STABLE / IMMUTABLE (default is VOLATILE)[docs]
  • BigQuery does not support this (it infers it as best it can)
  • databricks use DETERMINISTIC (assumed nondeterministic unless declared)[docs]

Acceptance criteria

  • A volatility can be declared in a function's config
  • By default the volatility of a function is None
  • A volatility can be defined as deterministic, stable, non-deterministic, or None`

These next two should be moved the dbt-adapters related issue once it exists

  • If a volatility is specified for a function, then the create function statement run against the data warehouse uses the appropriate volatility keyword
  • If volatility is None for a function, then no volatility keyword is used in the create function statement run against the data warehouse.

Suggested Tests

Can specify a volatility

Impact to Other Teams

N/A

Will backports be required?

No

Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2UDFsWork related to UDFsuser docs[docs.getdbt.com] Needs better documentation

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions