Why do data teams use separate environments like dev, staging, and prod in dbt projects?
Think about how changes are tested before affecting real data.
Separate environments help teams develop and test changes without affecting live data. Dev is for building, staging for testing, and prod for stable, live data.
Given this profiles.yml snippet, what is the active target when running dbt run --target staging?
my_project:
target: dev
outputs:
dev:
type: snowflake
database: dev_db
staging:
type: snowflake
database: staging_db
prod:
type: snowflake
database: prod_dbThe --target flag overrides the default target in the profile.
Running dbt run --target staging uses the staging output configuration, connecting to staging_db.
Consider this dbt model SQL snippet that uses an environment variable to filter data:
select * from raw.sales
where region = '{{ env_var('REGION', 'all') }}'If you run dbt run with REGION set to north, what will be the output?
Check how env_var uses the environment variable if set.
The env_var function uses the environment variable REGION if set, filtering rows to region = 'north'.
A model runs fine in dev but fails in prod with a missing table error. What is the most likely cause?
Think about differences in data availability between environments.
Missing tables or schemas in prod cause errors, while dev has them available.
You want to configure dbt to use different schemas for dev, staging, and prod environments automatically. Which dbt_project.yml snippet correctly sets the schema based on the active target?
Use the target variable to dynamically set schema names.
Using {{ target.name }}_schema sets schema names like dev_schema, staging_schema, or prod_schema automatically based on the active target.