Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Where to configure materialization

dbt · dbt Fundamentals

Where to configure materialization

Easydbt-06
configmaterializationdbt_project.ymlyaml

Question

Where can you configure a model's materialization in dbt?

Solution

You can set materialization (and other configs) in three common places. More specific settings win over more general ones.

1. Inside the model (most specific)

{{ config(materialized='table') }}

select * from {{ ref('stg_orders') }}

2. In a YAML properties / schema file

models:
  - name: fct_orders
    config:
      materialized: incremental
      unique_key: order_id

3. In dbt_project.yml (folder / project defaults)

models:
  my_project:
    staging:
      +materialized: view
    marts:
      +materialized: table

The + prefix in dbt_project.yml means "apply this config to models in this folder tree."

Precedence (mental model)

dbt_project.yml (folder defaults)
        ↑ overridden by
model YAML config
        ↑ overridden by
{{ config(...) }} in the .sql file

Practical pattern

  • Put layer defaults in dbt_project.yml (staging = view, marts = table).
  • Override special models in the file or YAML (one huge fact → incremental).

Interview tip: Mention hierarchy: project defaults → YAML → inline config(). Interviewers want to hear you avoid sprinkling materialized='table' on every file when a folder default would do.

PreviousNext