Model configurations

Related documentation

Available configurations

Model-specific configurations

dbt_project.yml
models:
materialized: <materialization_name>
sql_header: <string>

General configurations

dbt_project.yml
models:
enabled: true | false
tags: <string> | [<string>]
pre-hook: <sql-statement> | [<sql-statement>]
post-hook: <sql-statement> | [<sql-statement>]
database: <string>
schema: <string>
alias: <string>

Warehouse-specific configurations

Configuring models

Models can be configured in one of two ways:

  1. Using a config block within a model, or
  2. From the dbt_project.yml file, under the models: key. To apply a configuration to a snapshot, or directory of snapshots, define the resource path as nested dictionary keys.

Model configurations are applied hierarchically — configurations applied to a marketing subdirectory will take precedence over configurations applied to the entire jaffle_shop project.

Example

Configuring directories of models in dbt_project.yml

To configure models in your dbt_project.yml file, use the models: configuration option. Be sure to use namespace your configurations to your project (shown below):

# dbt_project.yml
name: fishtown_analytics
models:
# Be sure to namespace your model configs to your project name
fishtown_analytics:
# This configures models found in models/events/
events:
enabled: true
materialized: view
# This configures models found in models/events/base
# These models will be ephemeral, as the config above is overridden
base:
materialized: ephemeral
...

Apply configurations to one model only

Some types of configurations are specific to a particular model. In these cases, placing configurations in the dbt_project.yml file can be unwieldy. Instead, you can specify these configurations at the top of a model .sql file.

models/events/base/base_events.sql
{{
config(
materialized = "table",
sort = 'event_time',
dist = 'event_id'
)
}}
select * from ...