DBT-ANALYTICS-ENGINEERING practice question 8 of 35

True or False: In a modular dbt project, using the {{ source() }} function to reference raw data sources helps adhere to DRY principles.

Full set: 409 questions

Domain Source & staging data

Answer options
A: TRUE
B: FALSE
Correct Answer:
TRUE
Explanation

The statement is true. The {{ source() }} function in dbt is a core component for building modular and maintainable data projects that adhere to the "Don't Repeat Yourself" (DRY) principle. By defining raw data tables (including their database and schema) in a central sources.yml file, you create a single source of truth for these upstream dependencies. Downstream models then use the {{ source() }} function to reference these tables instead of hardcoding their full paths. If the location of a raw data table changes, the update only needs to be made in the single sources.yml file, rather than in every model that references it, thus avoiding repetition and reducing the risk of errors.

Why Incorrect

The statement is not false because the primary architectural benefit of the source() macro is to abstract and centralize the definition of raw data locations. Hardcoding the full path of a source table (e.g., raw.jaffleshop.orders) in multiple models would be a direct violation of the DRY principle, as the location information is repeated in each model. The source() function is designed specifically to prevent this repetition.

References

1. dbt Labs Official Documentation

"Sources": "By declaring sources in dbt

you can then select from source tables in your models using the {{ source() }} function... This provides a single place for you to define your source data

and all downstream models can reference it." This directly describes the centralization of information

which is the core of the DRY principle.

Source: dbt Labs Documentation

dbt Core > dbt-core fundamentals > Sources.

2. dbt Labs Official Documentation

"How we structure our dbt projects": This best practice guide emphasizes creating a clean interface between raw data and the rest of the dbt project. It states

"The purpose of [staging] models is to be representations of the source data... Each staging model should correspond to one source table." This one-to-one mapping and clean referencing is enabled by the source() function

promoting a modular and DRY structure.

Source: dbt Labs Documentation

Best practices > How we structure our dbt projects > Staging: preparing our raw data for modeling.

3. dbt Labs Official Documentation

"source function": The documentation for the function itself explains its role in referencing pre-defined sources. "The source function is the primary way to reference a source table in a model." This reinforces its role as the standardized method for referencing

which is essential for a DRY implementation.

Source: dbt Labs Documentation

Jinja & macros > Functions > source.

Scroll to Top