The dbt_project.yml file tells dbt how to run your project. It sets up important details like where your data models live and how to build them.
dbt_project.yml configuration
name: your_project_name version: '1.0' config-version: 2 profile: your_profile_name source-paths: ["models"] analysis-paths: ["analysis"] test-paths: ["tests"] target-path: "target" clean-targets: ["target", "dbt_modules"] models: your_project_name: +materialized: view staging: +schema: staging +materialized: table
The name is your project name and must match your folder name.
Indentation matters because YAML uses spaces to organize settings.
name: sales_analytics version: '1.0' config-version: 2 profile: prod_profile source-paths: ["models"] models: sales_analytics: +materialized: table
models:
sales_analytics:
staging:
+schema: staging
+materialized: incremental
marts:
+schema: marts
+materialized: viewThis dbt_project.yml configures a project named my_dbt_project. It sets the default materialization to view. The staging folder models build as tables in the staging schema. The marts folder models build incrementally in the marts schema.
name: my_dbt_project version: '1.0' config-version: 2 profile: default source-paths: ["models"] test-paths: ["tests"] target-path: "target" clean-targets: ["target", "dbt_modules"] models: my_dbt_project: +materialized: view staging: +schema: staging +materialized: table marts: +schema: marts +materialized: incremental
The dbt_project.yml file must be in your project root folder.
Use two spaces for indentation to avoid YAML errors.
You can override settings for specific folders or models under the models: section.
dbt_project.yml tells dbt how to run your project.
It sets project name, version, file paths, and model build settings.
Indentation and correct YAML format are important for it to work.
Practice
dbt_project.yml file in a dbt project?Solution
Step 1: Understand the role of
This file tells dbt how to run the project by setting configurations.dbt_project.ymlStep 2: Identify what configurations it includes
It sets project name, version, file paths, and model build settings, not SQL or data files.Final Answer:
To configure project settings like name, version, and model paths -> Option AQuick Check:
Project configuration = To configure project settings like name, version, and model paths [OK]
dbt_project.yml sets project-wide settings [OK]- Confusing
dbt_project.ymlwith SQL model files - Thinking it stores data instead of configurations
- Assuming it manages user permissions
dbt_project.yml?Solution
Step 1: Recall the correct key for project name in
The key to set the project name isdbt_project.ymlname, notproject_nameor others.Step 2: Check YAML syntax
YAML uses key: value pairs, soname: my_dbt_projectis correct syntax.Final Answer:
name: my_dbt_project -> Option DQuick Check:
Project name key = name [OK]
name: to set project name in YAML [OK]- Using underscores or hyphens incorrectly in key names
- Putting project name under wrong key
- Using quotes unnecessarily or missing them when needed
dbt_project.yml:
models:
my_project:
materialized: table
schema: analytics
What will be the materialization type and schema for models in the my_project namespace?Solution
Step 1: Read the materialized setting under models.my_project
The settingmaterialized: tablemeans models will be built as tables.Step 2: Check the schema setting
The schema is explicitly set toanalytics, so models will be created in that schema.Final Answer:
Materialized as tables, schema is analytics -> Option BQuick Check:
Materialized = table, schema = analytics [OK]
materialized and schema keys under models [OK]- Assuming default schema when schema is set
- Confusing materialized types like view vs table
- Ignoring indentation that defines scope
dbt_project.yml snippet:
name: my_project
version: 1.0
models:
my_project:
materialized: table
schema analyticsSolution
Step 1: Check YAML syntax for key-value pairs
Each key must be followed by a colon and a space before the value. Here,schema analyticsmisses the colon.Step 2: Verify other parts
Indentation and version format are correct; project name uses correct keyname.Final Answer:
Missing colon after 'schema' key -> Option CQuick Check:
YAML key-value needs colon [OK]
- Forgetting colon after keys
- Wrong indentation levels
- Using wrong keys for project name
sales folder are materialized as incremental and use the schema sales_data. Which dbt_project.yml snippet correctly achieves this?Solution
Step 1: Understand dbt config syntax for folder-level overrides
To set configs for all models in a folder, use the '+' prefix before keys.Step 2: Check which options use '+' for both keys
Bothmaterializedandschemaneed '+' prefix to apply to all models insalesfolder.Final Answer:
models: sales: +materialized: incremental +schema: sales_data -> Option AQuick Check:
Folder configs use '+' prefix [OK]
- Missing '+' prefix for folder-level configs
- Using '+' on only one key instead of both
- Confusing folder name with project name
Ready to prove it?
Pass the test and this pattern moves unknown
