DBT-ANALYTICS-ENGINEERING practice question 5 of 35
You discover that a dbt model is directly referencing a raw object in the database without using the {{ source() }} function. What potential risks does this pose to the project?
Full set: 409 questionsDomain Environments & deployments
Bypassing the {{ source() }} function and directly referencing raw database objects breaks two core dbt principles. First, it severs the dependency link between the model and its raw data source within dbt's Directed Acyclic Graph (DAG). This prevents dbt from tracking lineage, running source-specific commands (e.g., dbt test source:), and checking for data freshness. Second, it harms maintainability. If the location or name of the raw data changes, developers must manually find and replace every hardcoded reference across the project. Using source() centralizes this definition in a single sources.yml file, making updates simple and reliable.
A. Reduced execution time: The source() function is a compile-time Jinja macro; it has no material impact on the final query's execution performance.
B. Increased complexity and poor maintainability: This is correct but incomplete, as it omits the critical issue of dependency management and lineage.
C. Dependency management issues: This is also correct but incomplete, as it overlooks the significant negative impact on project maintainability.
1. dbt Labs Official Documentation
"Sources": This document explains that using the source function is the standard way to refer to raw data. It states
"dbt builds the DAG of your project by parsing all of the ref and source calls in your models." By not using source()
the dependency is omitted from the DAG
leading to dependency management issues. The document also highlights benefits like testing and freshness checks
which are lost without proper source declaration.
Source: dbt Labs Documentation
docs/build/sources
Section: "Referring to sources".
2. dbt Labs Official Documentation
"Best practices": The guide on structuring dbt projects explicitly states that raw data should be declared as sources. This practice promotes maintainability by abstracting the raw table names and schemas into configuration files
preventing hardcoded values that are difficult to manage.
Source: dbt Labs Documentation
best-practices/how-we-structure/1-guide-overview
Section: "Sources".
3. dbt Labs Official Documentation
"source function": This page details how the source function renders a relation into your compiled SQL. It is the mechanism that allows dbt to understand the upstream dependencies of a model on raw data
which is fundamental for building the project's lineage graph.
Source: dbt Labs Documentation
reference/dbt-jinja-functions/source.
Keep practicing
Take the free DBT-ANALYTICS-ENGINEERING practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DBT-ANALYTICS-ENGINEERING practice questions
- Question 1What is the purpose of the --resource-type argument in the dbt ls command?
- Question 2Select the valid methods for configuring incremental models in dbt. (Select all that appl…
- Question 3When fixing a dbt model issue, it is acceptable to skip the testing process in a separate…
- Question 4You want to run tests on only the models that have been modified since your last dbt run.…
- Question 6What is the purpose of the dbt deps command in the dbt workflow?
- Question 7Which of the following commands will generate compiled SQL code and save it to the "targe…
