Introduction

In dbt, the dbt_project.yml file is the backbone of your project configuration. It controls how dbt behaves, where it looks for different resource types, and how your models are materialized and organized. In this tutorial, we'll walk through a sample dbt_project.yml file and explore its key configurations.

💡
Since this topic is relevant for the dbt Analytics Engineering Certification Exam, this guide will be a valuable resource on your way passing the exam. 👨‍🎓

📁 What is dbt_project.yml?

The dbt_project.yml file is the primary configuration file in any dbt project. It defines metadata and settings such as your project name, version compatibility, file paths, materialization behavior, documentation appearance, and more. This file is essential to how dbt interprets and executes your SQL models and other project assets.

🧱 Basic Structure of dbt_project.yml

Here’s a minimal example of dbt_project.yml:

name: 'dlnerds_university'

config-version: 2
version: '0.1'

profile: 'dlnerds_university'

model-paths: ["models"]
seed-paths: ["seeds"]
test-paths: ["tests"]
analysis-paths: ["analysis"]
macro-paths: ["macros"]

target-path: "target"
clean-targets:
    - "target"
    - "dbt_modules"
    - "logs"

require-dbt-version: [">=1.0.0", "<2.0.0"]

Let’s walk through the specific configurations:

Key Value Description
name dlnerds_university The name of your dbt project.
config-version 2 Version of the dbt_project.yml config format (v2 is current standard).
version '0.1' The version of your dbt project, useful for tracking releases or iterations.
profile dlnerds_university The dbt profile to use; links to database connection settings in profiles.yml.
model-paths ["models"] Folder where your dbt models are stored.
seed-paths ["seeds"] Folder containing CSV seed files to be loaded into your data warehouse.
test-paths ["tests"] Folder containing custom test files.
analysis-paths ["analysis"] Folder with models only for analysis.
macro-paths ["macros"] Folder containing reusable dbt macros.
target-path "target" Directory where dbt compiles SQL and stores run artifacts.
clean-targets ["target", "dbt_modules", "logs"] Directories/files to be removed when running dbt clean (cleanup command).
require-dbt-version [">=1.0.0", "<2.0.0"] Specifies supported dbt CLI versions (here >=1.0.0 and <2.0.0).

⚙️ Defining Seed and Model Configurations

You can set model-specific configurations such as materializations and database settings either globally or for specific directories and subdirectories using the seeds: and models: sections.

Here’s an example configuration that sets different configurations such as the materialization type, the schema and the documentation node color:

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In