Changing Model Configuration
Learn how to customize model configurations in dbt for efficient data management.
Config blocks
dbt allows us to specify configurations for our models. One way to do so is to edit the dbt_project.yml
file:
Press + to interact
# Name your project! Project names should contain only lowercase characters# and underscores. A good package name should reflect your organization's# name or the intended use of these modelsname: 'digital_marketing'version: '1.0.0'config-version: 2# This setting configures which "profile" dbt uses for this project.profile: 'marketing'# These configurations specify where dbt should look for different types of files.# The `model-paths` config, for example, states that models in this project can be# found in the "models/" directory. You probably won't need to change these!model-paths: ["models"]analysis-paths: ["analyses"]test-paths: ["tests"]seed-paths: ["seeds"]macro-paths: ["macros"]snapshot-paths: ["snapshots"]target-path: "target" # directory which will store compiled SQL filesclean-targets: # directories to be removed by `dbt clean`- "target"- "dbt_packages"# Configuring models# Full documentation: https://docs.getdbt.com/docs/configuring-models# In this example config, we tell dbt to build all models in the example/ directory# as tables. These settings can be overridden in the individual model files# using the `{{ config(...) }}` macro.models:test_project:+materialized: viewfolder1:+dataset: folder1folder2:+materialized: table
We can also change the configuration at the model level and override the configuration in the dbt_project.yml
file by using “config blocks.” Here’s an example of a config block for the case where we want to keep the model file stored in our code repository but disabled:
Press + to interact
{{ config(enabled=false) }}SELECT 1 AS id
dbt always applies configuration in the following order:
First, it looks at the model configuration.
If there’s no config block in the model file, it applies the project configuration.
Otherwise, it applies the default ...