0
0
dbtdata~20 mins

Loading CSV seeds in dbt - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Seed Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of seed loading with incremental model

Given a dbt seed file products.csv with 3 rows, and an incremental model that selects all rows from this seed, what will be the number of rows in the model after two runs if the seed file is unchanged?

dbt
models/incremental_products.sql

{{ config(materialized='incremental', unique_key='product_id') }}

select * from {{ ref('products') }}
A3 rows
B6 rows
C0 rows
DError due to duplicate keys
Attempts:
2 left
💡 Hint

Think about how incremental models handle existing rows with the same unique key.

data_output
intermediate
2:00remaining
Data output after loading a CSV seed with transformations

You have a seed CSV file sales.csv with columns date, amount. You create a dbt model that loads this seed and adds a new column amount_taxed which is amount * 1.1. What is the output table if the seed has rows:

date,amount
2024-01-01,100
2024-01-02,200
dbt
select date, amount, amount * 1.1 as amount_taxed from {{ ref('sales') }}
A[{'date': '2024-01-01', 'amount': 100, 'amount_taxed': 110.0}, {'date': '2024-01-02', 'amount': 200, 'amount_taxed': 220.0}]
B[{'date': '2024-01-01', 'amount': 100, 'amount_taxed': 100.0}, {'date': '2024-01-02', 'amount': 200, 'amount_taxed': 200.0}]
C[{'date': '2024-01-01', 'amount': 110, 'amount_taxed': 110.0}, {'date': '2024-01-02', 'amount': 220, 'amount_taxed': 220.0}]
D[{'date': '2024-01-01', 'amount': 100, 'amount_taxed': null}, {'date': '2024-01-02', 'amount': 200, 'amount_taxed': null}]
Attempts:
2 left
💡 Hint

Remember to multiply the amount by 1.1 to get amount_taxed.

🔧 Debug
advanced
2:00remaining
Identify the error when loading a CSV seed with invalid config

Consider this dbt seed configuration in dbt_project.yml:

seeds:
  my_project:
    sales:
      file: sales_data.csv
      delimiter: ';'
      header: false

What error will occur when running dbt seed?

AError: The seed file 'sales_data.csv' is missing header row but 'header' is set to false, causing parsing failure.
BError: Delimiter ';' is not supported by dbt seed.
CNo error, seed loads successfully with semicolon delimiter and no header.
DError: Invalid config key 'file' in seed configuration.
Attempts:
2 left
💡 Hint

Check the valid configuration keys for seeds in dbt.

🧠 Conceptual
advanced
2:00remaining
Understanding seed freshness and reload behavior

When you run dbt seed multiple times without changing the CSV file, what happens to the data in the database table created by the seed?

AThe seed command does nothing if the CSV file is unchanged.
BThe table is dropped and recreated each time, so data is replaced with the CSV content.
CNew rows are appended to the existing table, causing duplicates.
DThe table is updated only if the CSV file has a newer timestamp.
Attempts:
2 left
💡 Hint

Think about how dbt seed manages the target table on each run.

🚀 Application
expert
3:00remaining
Predict the output of a seed with mixed data types and nulls

You have a seed CSV users.csv with columns id, name, age:

id,name,age
1,Alice,30
2,Bob,
3,Charlie,25

You load this seed in dbt and run a model that selects all rows where age > 25. What rows will the model return?

dbt
select * from {{ ref('users') }} where age > 25
A[{'id': 1, 'name': 'Alice', 'age': 30}, {'id': 2, 'name': 'Bob', 'age': null}]
B[{'id': 1, 'name': 'Alice', 'age': 30}, {'id': 3, 'name': 'Charlie', 'age': 25}]
C[{'id': 1, 'name': 'Alice', 'age': 30}]
D[]
Attempts:
2 left
💡 Hint

Remember that null values do not satisfy comparison operators like >.