profiles.yml sets one warehouse for the whole run. Most models run fine on a small one, but a few large joins or incremental merges would finish much sooner on a bigger warehouse. snowflake_warehouse switches warehouse for those models only.

Copy and paste

One model:

{{ config(snowflake_warehouse='TRANSFORMING_L') }}

A folder, in dbt_project.yml:

models:
  shop:
    marts:
      finance:
        +snowflake_warehouse: TRANSFORMING_L

Only in production, keeping the profile’s warehouse elsewhere:

{{ config(snowflake_warehouse='TRANSFORMING_L' if target.name == 'prod' else target.warehouse) }}

Give the dbt role access to the extra warehouse:

grant usage on warehouse TRANSFORMING_L to role TRANSFORMER;

How dbt switches

Before a node with snowflake_warehouse runs, dbt-snowflake executes use warehouse TRANSFORMING_L on its connection. After the node, it switches back to the warehouse it was using. When the configured warehouse is the same as the one in the profile, dbt does nothing. Tests and snapshots can have the setting too.

The name is used as written, without quotes, so Snowflake reads it in uppercase.

Choosing which models

If it fails

An error on the use warehouse statement, typically Object does not exist, or operation cannot be performed, means the role in the profile cannot use that warehouse, or the name is wrong. Grant USAGE as above, and check the name.

The switching logic comes from the code of dbt-snowflake 1.12.4; not run against a live Snowflake account.

References