Skip to main content

Configuring materializations

Configuring materializations

Choosing which materialization is as simple as setting any other configuration in dbt. We’ll look first at how we select our materializations for individual models, then at more powerful ways of setting materializations for entire folders of models.

Configuring tables and views

Let’s look at how we can use tables and views to get started with materializations:

  • ⚙️ We can configure an individual model’s materialization using a Jinja config block, and passing in the materialized argument. This tells dbt what materialization to use.
  • 🚰 The underlying specifics of what is run depends on which adapter you’re using, but the end results will be equivalent.
  • 😌 This is one of the many valuable aspects of dbt: it lets us use a declarative approach, specifying the outcome that we want in our code, rather than specific steps to achieve it (the latter is an imperative approach if you want to get computer science-y about it 🤓).
  • 🔍 In the below case, we want to create a view, and can declare that in a single line of code.
    {{
config(
materialized='view'
)
}}

select ...
info

🐍 Not all adapters support python yet, check the docs here to be sure before spending time writing python models.

  • Configuring a model to materialize as a table is simple, and the same as a view for both SQL and python models.
{{
config(
materialized='table'
)
}}

select ...

Go ahead and try some of these out!

0