0
0
dbtdata~5 mins

source() function for raw tables in dbt - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the source() function in dbt?
The source() function in dbt is used to reference raw tables or external data sources in your project. It helps you track and document where your data comes from.
Click to reveal answer
beginner
How do you use the source() function in a dbt model?
You use source('source_name', 'table_name') inside your SQL to refer to a raw table defined in your sources.yml file. This makes your code clear and maintainable.
Click to reveal answer
beginner
What file do you configure to define sources for the source() function?
You define sources in a sources.yml file inside your dbt project. This file lists the source names and their raw tables with metadata.
Click to reveal answer
intermediate
Why is using source() better than hardcoding raw table names?
Using source() helps track data lineage, improves documentation, and makes your project easier to update if raw table names or locations change.
Click to reveal answer
intermediate
Can source() be used to reference tables outside your dbt project?
Yes, source() can reference external raw tables as long as they are defined in your sources.yml file and accessible by your data warehouse.
Click to reveal answer
What does source('raw', 'customers') do in dbt?
AReferences the 'customers' table from the 'raw' source defined in sources.yml
BCreates a new table called 'customers' in the 'raw' schema
CDeletes the 'customers' table from the 'raw' source
DRuns a transformation on the 'customers' table
Where do you define the sources used by the source() function?
AIn the <code>models/</code> folder
BIn the <code>sources.yml</code> file
CIn the <code>dbt_project.yml</code> file
DIn the SQL model files
Why should you use source() instead of hardcoding table names?
ATo improve data lineage and documentation
BTo speed up query execution
CTo automatically create tables
DTo encrypt data
Can source() reference tables outside your dbt project?
ANo, only tables inside the project
BOnly if you use a special plugin
CYes, if defined in <code>sources.yml</code> and accessible
DOnly for views, not tables
What is the correct syntax to reference a source table named 'orders' in source 'raw_data'?
A<code>source('orders', 'raw_data')</code>
B<code>ref('orders', 'raw_data')</code>
C<code>ref('raw_data', 'orders')</code>
D<code>source('raw_data', 'orders')</code>
Explain how the source() function helps manage raw tables in dbt projects.
Think about how you keep track of where your data comes from.
You got /4 concepts.
    Describe the steps to set up and use the source() function for a new raw table.
    Start from configuration, then usage, then benefits.
    You got /4 concepts.