dbt-labs / dbt-labs/docs.getdbt.com

Revamp explanation of `execute` Jinja variable when handled by the dbt Fusion engine

Open
#7,395 0 comments 0 reactions 1 assignee Claimed by @joellabes View on GitHub
content improvement
Dominant language
JavaScript
Stars
215
Forks
1.2k
Avg merge
1d 15h
Merged PRs (30d)
130

Description

### Contributions

- [x] I have read the contribution docs, and understand what's expected of me.

### Link to the page on docs.getdbt.com requiring updates

https://docs.getdbt.com/reference/dbt-jinja-functions/execute

### What part(s) of the page would you like to see updated?

[Via this discussion](https://getdbt.slack.com/archives/C088YCAB6GH/p1748824362110399?thread_ts=1748579427.732689&cid=C088YCAB6GH)

> As per your suggestion, I've now fixed this by moving things to pre-hooks when they should be. I do want to point out that the docs you linked could easily mislead people to believe the execute variable will only be true if SQL execution will also occur. In retrospect it seems obvious, but since we almost never compiled our models outside of scenarios that also ran the SQL, our misunderstanding wasn't exposed until now.
>
> Here's what the docs say:
> > 1. Reads all of the files in your project and generates a manifest comprised of models, tests, and other graph nodes present in your project. During this phase, dbt uses the ref and source statements it finds to generate the DAG for your project. **No SQL is run during this phase**, and execute == False.
> > 2. Compiles (and runs) each node (eg. building models, or running tests). **SQL is run during this phase**, and execute == True.
>
> An example of a way to make this clearer:
>
> > 1. Reads all of the files in your project and generates a manifest comprised of models, tests, and other graph nodes present in your project. During this phase, dbt uses the ref and source statements it finds to generate the DAG for your project. **No SQL is run during this phase**, and execute == False.
> > 2. Compiles each node. Here execute == True, so **any calls to run_query() will execute SQL, but none of the model's SQL will run.**
> > 3. Runs the model. Here, execute is irrelevant as all Jinja compilation has occurred. **This is when your model's SQL will run.**

Making a note for myself to come back and have a swing at the docs with this context. In particular I think it's worth teasing out the difference between rendering the SQL, compiling the SQL and executing the SQL. Some of this is handled in the https://docs.getdbt.com/docs/fusion/new-concepts doc but it is extra relevant here.

### Additional information

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.