What if you could fix broken data queries by changing just one place instead of many?
Why source() function for raw tables in dbt? - Purpose & Use Cases
Imagine you have many raw data tables coming from different systems. You want to use them in your data models, but you have to write full table names everywhere, and keep track of where each table lives.
Manually typing full table names is slow and easy to mess up. If a table moves or changes, you must update every place you used it. This causes errors and wastes time.
The source() function lets you define raw tables once and then refer to them simply. It keeps your code clean and safe from changes in table locations.
select * from raw_database.raw_schema.customersselect * from {{ source('raw_database', 'customers') }}
You can build reliable data models that easily adapt when raw tables move or change.
A data analyst uses source() to refer to sales data tables. When the data warehouse reorganizes, only the source definition changes, not all the queries.
Manually writing full raw table names is error-prone and hard to maintain.
source() centralizes raw table references for cleaner code.
This makes your data models more reliable and easier to update.