dbt_project.yml
Every dbt project needs a dbt_project.yml
file — this is how dbt knows a directory is a dbt project. It also contains important information that tells dbt how to operate your project.
-
dbt uses YAML in a few different places. If you're new to YAML, it would be worth learning how arrays, dictionaries, and strings are represented.
-
By default, dbt looks for the
dbt_project.yml
in your current working directory and its parents, but you can set a different directory using the--project-dir
flag or theDBT_PROJECT_DIR
environment variable. -
Specify your dbt Cloud project ID in the
dbt_project.yml
file usingproject-id
under thedbt-cloud
config. Find your project ID in your dbt Cloud project URL: For example, inhttps://YOUR_ACCESS_URL/11/projects/123456
, the project ID is123456
. -
Note, you can't set up a "property" in the
dbt_project.yml
file if it's not a config (an example is macros). This applies to all types of resources. Refer to Configs and properties for more detail.
Example
The following example is a list of all available configurations in the dbt_project.yml
file:
name: string
config-version: 2
version: version
profile: profilename
model-paths: [directorypath]
seed-paths: [directorypath]
test-paths: [directorypath]
analysis-paths: [directorypath]
macro-paths: [directorypath]
snapshot-paths: [directorypath]
docs-paths: [directorypath]
asset-paths: [directorypath]
packages-install-path: directorypath
clean-targets: [directorypath]
query-comment: string
require-dbt-version: version-range | [version-range]
flags:
<global-configs>
dbt-cloud:
project-id: project_id # Required
defer-env-id: environment_id # Optional
quoting:
database: true | false
schema: true | false
identifier: true | false
metrics:
<metric-configs>
models:
<model-configs>
seeds:
<seed-configs>
semantic-models:
<semantic-model-configs>
saved-queries:
<saved-queries-configs>
snapshots:
<snapshot-configs>
sources:
<source-configs>
tests:
<test-configs>
vars:
<variables>
on-run-start: sql-statement | [sql-statement]
on-run-end: sql-statement | [sql-statement]
dispatch:
- macro_namespace: packagename
search_order: [packagename]
restrict-access: true | false
Naming convention
It's important to follow the correct YAML naming conventions for the configs in your dbt_project.yml
file to ensure dbt can process them properly. This is especially true for resource types with more than one word.
-
Use dashes (
-
) when configuring resource types with multiple words in yourdbt_project.yml
file. Here's an example for saved queries:dbt_project.ymlsaved-queries: # Use dashes for resource types in the dbt_project.yml file.
my_saved_query:
+cache:
enabled: true -
Use underscore (
_
) when configuring resource types with multiple words for YAML files other than thedbt_project.yml
file. For example, here's the same saved queries resource in thesemantic_models.yml
file:models/semantic_models.ymlsaved_queries: # Use underscores everywhere outside the dbt_project.yml file.
- name: saved_query_name
... # Rest of the saved queries configuration.
config:
cache:
enabled: true