0
0
dbtdata~20 mins

source() function for raw tables in dbt - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Source Function Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of source() function call in dbt
Given the following dbt model code snippet, what will be the output SQL generated for the source table reference?
dbt
select * from {{ source('raw_data', 'users') }}
Aselect * from raw_data.users
Bselect * from {{ raw_data.users }}
Cselect * from source.raw_data.users
Dselect * from raw_data__users
Attempts:
2 left
💡 Hint
The source() function returns a fully qualified table name using the source schema and table name.
🧠 Conceptual
intermediate
1:30remaining
Purpose of source() function in dbt
What is the main purpose of using the source() function in a dbt model?
ATo define incremental models
BTo create new tables in the database
CTo run raw SQL queries without transformation
DTo reference raw tables defined in the source.yml file for better lineage and documentation
Attempts:
2 left
💡 Hint
Think about how dbt tracks raw data sources and their metadata.
🔧 Debug
advanced
2:00remaining
Identify the error in source() usage
What error will occur when running this dbt model code? select * from {{ source('raw_data') }}
dbt
select * from {{ source('raw_data') }}
ARuntime error: table raw_data does not exist
BCompilation error: source() requires two arguments: source name and table name
CNo error, runs successfully
DSyntax error in SQL due to missing quotes
Attempts:
2 left
💡 Hint
Check the number of arguments source() expects.
data_output
advanced
2:00remaining
Resulting SQL from nested source() usage
What is the resulting SQL query from this dbt model code? select user_id, count(*) from {{ source('raw_data', 'events') }} group by user_id
dbt
select user_id, count(*) from {{ source('raw_data', 'events') }} group by user_id
Aselect user_id, count(*) from raw_data.events group by user_id
Bselect user_id, count(*) from source.raw_data.events group by user_id
Cselect user_id, count(*) from raw_data__events group by user_id
Dselect user_id, count(*) from {{ raw_data.events }} group by user_id
Attempts:
2 left
💡 Hint
Remember how source() resolves to schema.table format.
🚀 Application
expert
2:30remaining
Using source() with multiple environments
In a dbt project with multiple environments (dev, prod), how does the source() function help manage raw table references across environments?
AIt automatically copies raw tables from prod to dev
BIt requires hardcoding schema names for each environment in the model code
CIt dynamically resolves the schema based on the environment, allowing the same model code to work in dev and prod
DIt disables source tracking in non-prod environments
Attempts:
2 left
💡 Hint
Think about how dbt profiles and source configurations work.