Bird
Raised Fist0
dbtdata~20 mins

dbt project structure - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
šŸŽ–ļø
dbt Project Structure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the purpose of the 'models' directory in a dbt project?

In a dbt project, the 'models' directory is a key folder. What is its main purpose?

AIt stores SQL files that define transformations and create tables or views in the data warehouse.
BIt contains configuration files for database connections and credentials.
CIt holds documentation files describing the project goals and team members.
DIt stores raw data files imported directly into the data warehouse.
Attempts:
2 left
šŸ’” Hint

Think about where you write the SQL code that builds your data models.

ā“ Predict Output
intermediate
2:00remaining
What does the 'dbt_project.yml' file configure?

Given a dbt project, what is the main role of the dbt_project.yml file?

AIt defines project-level configurations like model paths, version, and materializations.
BIt contains SQL queries for data transformations.
CIt stores user credentials for the data warehouse connection.
DIt holds the compiled data models after dbt runs.
Attempts:
2 left
šŸ’” Hint

Think about where you set project-wide settings in dbt.

ā“ data_output
advanced
2:00remaining
How many SQL model files are in this 'models' directory structure?

Suppose your dbt project has this 'models' folder structure:

models/
ā”œā”€ā”€ staging/
│   ā”œā”€ā”€ customers.sql
│   └── orders.sql
ā”œā”€ā”€ marts/
│   ā”œā”€ā”€ sales.sql
│   └── inventory.sql
└── README.md

How many SQL model files will dbt compile and run?

A5
B3
C2
D4
Attempts:
2 left
šŸ’” Hint

Count only the .sql files inside the 'models' folder and its subfolders.

šŸ”§ Debug
advanced
2:00remaining
Why does dbt fail to find models in this project?

You have this dbt_project.yml snippet:

name: my_project
version: '1.0'
model-paths: ['sql_models']

But your models are inside a folder named models. What is the cause of the problem?

AThe <code>version</code> number must be an integer, not a string.
BThe <code>model-paths</code> setting points to 'sql_models', but the actual folder is named 'models'.
CThe <code>name</code> field should be inside the 'models' folder.
DThe <code>dbt_project.yml</code> file must be named <code>project.yml</code>.
Attempts:
2 left
šŸ’” Hint

Check if the folder path matches the actual folder name.

šŸš€ Application
expert
2:00remaining
Which folder should you place test SQL files in a dbt project?

You want to add custom data quality tests using SQL in your dbt project. Where should you place these test files?

AInside the 'models' directory alongside your model SQL files.
BInside the 'data' directory used for seed files.
CInside the 'tests' directory at the root of the dbt project.
DInside the 'macros' directory because tests are macros.
Attempts:
2 left
šŸ’” Hint

Think about where dbt expects test files to be stored.

Practice

(1/5)
1. Which folder in a dbt project typically contains SQL files that define your data transformations?
easy
A. snapshots/
B. models/
C. macros/
D. tests/

Solution

  1. Step 1: Understand folder purposes

    The models/ folder is where SQL files for data transformations live.
  2. Step 2: Identify correct folder for SQL models

    Other folders like macros/ hold reusable code, snapshots/ hold snapshot definitions, and tests/ hold test files.
  3. Final Answer:

    models/ -> Option B
  4. Quick Check:

    Data transformations = models/ folder [OK]
Hint: Models folder holds SQL transformations [OK]
Common Mistakes:
  • Confusing macros/ with models/
  • Thinking snapshots/ holds models
  • Assuming tests/ contains SQL models
2. Which of the following is the correct name for the main configuration file in a dbt project?
easy
A. dbt_project.yml
B. dbt_config.yml
C. project.yaml
D. dbt_settings.yml

Solution

  1. Step 1: Recall main config file name

    The main configuration file for dbt projects is named dbt_project.yml.
  2. Step 2: Verify other options

    Other options like dbt_config.yml or dbt_settings.yml are incorrect names.
  3. Final Answer:

    dbt_project.yml -> Option A
  4. Quick Check:

    Main config file = dbt_project.yml [OK]
Hint: Main config file always named dbt_project.yml [OK]
Common Mistakes:
  • Using dbt_config.yml instead
  • Confusing with generic project.yaml
  • Assuming settings file controls project
3. Given this dbt project structure snippet:
my_dbt_project/
ā”œā”€ā”€ models/
│   ā”œā”€ā”€ customers.sql
│   └── orders.sql
ā”œā”€ā”€ macros/
│   └── date_utils.sql
└── dbt_project.yml

Which file would you edit to add a reusable SQL function?
medium
A. models/customers.sql
B. dbt_project.yml
C. macros/date_utils.sql
D. models/orders.sql

Solution

  1. Step 1: Identify purpose of macros/ folder

    The macros/ folder holds reusable SQL functions and macros.
  2. Step 2: Locate reusable function file

    The file macros/date_utils.sql is the right place to add reusable SQL functions.
  3. Final Answer:

    macros/date_utils.sql -> Option C
  4. Quick Check:

    Reusable SQL functions = macros/ folder [OK]
Hint: Reusable SQL code goes in macros/ folder [OK]
Common Mistakes:
  • Adding functions inside models/ files
  • Editing dbt_project.yml for SQL code
  • Confusing macros/ with models/
4. You see this error when running dbt: Compilation Error: Could not find model 'sales_summary'. Which is the most likely cause related to project structure?
medium
A. The 'sales_summary.sql' file is missing from the models/ folder.
B. The 'sales_summary.sql' file is inside the macros/ folder.
C. The dbt_project.yml file is missing.
D. The snapshots/ folder contains 'sales_summary.sql'.

Solution

  1. Step 1: Understand error meaning

    The error means dbt cannot find the model named 'sales_summary'.
  2. Step 2: Check model file location

    Models must be in the models/ folder. If the file is missing there, dbt can't compile it.
  3. Final Answer:

    The 'sales_summary.sql' file is missing from the models/ folder. -> Option A
  4. Quick Check:

    Missing model file in models/ causes compilation error [OK]
Hint: Models must be in models/ folder to compile [OK]
Common Mistakes:
  • Placing model files in macros/ folder
  • Assuming missing dbt_project.yml causes this error
  • Confusing snapshots/ with models/
5. You want to organize your dbt project so that models related to customers and orders are in separate folders inside models/. How should you update your dbt_project.yml to reflect this structure?
hard
A. Add models: my_dbt_project: +materialized: view only
B. No changes needed; dbt auto-detects subfolders without config
C. Add macros: my_dbt_project: customers: +materialized: table
D. Add models: my_dbt_project: customers: +materialized: table orders: +materialized: table

Solution

  1. Step 1: Understand folder-specific config in dbt_project.yml

    You can specify configs per subfolder inside models/ by nesting them under your project name.
  2. Step 2: Define separate configs for customers and orders folders

    Adding customers: and orders: keys with materialization settings applies configs to those subfolders.
  3. Final Answer:

    Add models: my_dbt_project: customers: +materialized: table orders: +materialized: table -> Option D
  4. Quick Check:

    Use nested keys in dbt_project.yml for subfolder configs [OK]
Hint: Use nested keys in dbt_project.yml for subfolder configs [OK]
Common Mistakes:
  • Not nesting configs under project name
  • Configuring macros instead of models
  • Assuming no config needed for subfolders