Skip to main content

evaluate_volatile_sql

dbt_project.yml
models:
<resource-path>:
+state:
evaluate_volatile_sql: true | false

Definition

dbt State determines whether a node's data has changed based on the freshness of its parents. However, volatile SQL functions like CURRENT_TIMESTAMP(), RANDOM(), or UUID_STRING() can change a node's output from one run to the next even when no upstream data has changed.

By default, dbt State treats volatile functions as static parts of the node's compiled code, not as a source of new data. This is the right choice in most cases — otherwise, no node containing CURRENT_TIMESTAMP() would ever be reusable.

When evaluate_volatile_sql is set to true, dbt State stores the result of each volatile function call and uses those stored values for future comparisons. This means the node is rebuilt when the function's output changes — for example, when current_date() returns a new value after midnight.

ValueBehavior
false (default)Volatile functions are treated as static code. The node can be reused even if function outputs would differ between runs.
truedbt State stores and compares the runtime result of volatile functions. The node rebuilds when those results change.
Loading table...

Examples

Rebuild when the date changes

Use evaluate_volatile_sql: true for a node whose output is meaningfully affected by the current date:

models/<filename>.sql
{{ config(state={"evaluate_volatile_sql": true}) }}

select
*,
account_created_at >= current_date() as signed_up_today
from {{ ref('dim_customers') }}

With this config enabled, dbt State stores the result of current_date() after each build. On the next run after midnight, the stored value no longer matches and the node is rebuilt, even if dim_customers hasn't changed.

Default behavior

For nodes where volatile function output doesn't affect business logic, no config is required:

models/<filename>.sql
select
*,
getdate() as _dbt_built_at
from {{ ref('dim_customers') }}

dbt State treats getdate() as static code. The node remains reusable as long as its parents haven't changed.

Was this page helpful?

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

0
Loading