DBT-ANALYTICS-ENGINEERING practice question 7 of 35

Which of the following commands will generate compiled SQL code and save it to the "target" folder, but not execute it in the database?

Full set: 409 questions

Domain Modeling

Answer options
A: dbt run
B: dbt debug
C: dbt test
D: dbt compile Correct answer
Correct Answer:
D. dbt compile
Explanation

The dbt compile command is specifically designed to generate executable SQL from your project's source files, which include models, tests, and other Jinja-templated code. It processes all the Jinja logic and saves the resulting pure SQL files into the target/ directory. A key characteristic of this command is that it does not execute the compiled SQL against your data warehouse. This allows developers to inspect the generated SQL for correctness or debugging purposes without altering the database state.

Why Incorrect

A. dbt run: This command compiles the SQL and then immediately executes it against the target database to create or update tables and views.
B. dbt debug: This is a utility command used for troubleshooting project setup and database connectivity; it does not compile models into SQL.
C. dbt test: This command executes predefined data tests by running their corresponding SQL queries against the database to validate assumptions about your models.

References

1. dbt Labs Documentation, dbt compile command: "Generates executable SQL from your project's source files. You can find these compiled SQL files in the target/ directory of your project. This command does not run the SQL against your database." (Source: dbt Labs, dbt Command reference, section on dbt compile).

2. dbt Labs Documentation, dbt run command: "dbt will compile the model code into SQL, then execute that SQL against the configured target database." (Source: dbt Labs, dbt Command reference, section on dbt run).

3. dbt Labs Documentation, dbt debug command: "A helpful command for debugging your dbt project and your connection to the database. This command does not run any models or tests." (Source: dbt Labs, dbt Command reference, section on dbt debug).

Scroll to Top