In dbt, what is the difference between ref and source?
💡 Model Answer
In dbt, ref() and source() are two functions used to reference tables, but they serve different purposes. ref() is used to reference another dbt model within the same project. It creates a dependency graph so that dbt knows the order of execution and can rebuild only the affected models when a change occurs. source() is used to reference external tables that are not managed by dbt, such as raw tables in a data warehouse. It tells dbt where to find the data but does not create a dependency; instead, it allows you to document and test those tables. In practice, you use ref() for internal transformations and source() for raw, external data. This distinction helps maintain clear lineage and ensures efficient incremental builds.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500