When you dbt compile
, dbt at a very high level does this:
- read your dbt_project.yml in, rendering most fields with jinja (hooks and query comments are deferred until later, when they can have more information available). Any projects in your modules directory are also read in and rendered - consider them part of "your project" when reading.
- read your profiles.yml in, rendering everything with jinja
- find all the relevant files (.sql, .yml) and read them in, as defined in your dbt_project.yml
- dbt renders each sql file with jinja, primarily collecting calls to
ref
,source
, andconfig
. The string result of the actual rendering is then discarded. The model's materialization type is finalized here, as are any other relevant model-level configuration items (database/schema/alias are easy examples here!). - build a dependency graph using the
ref
information and use the command-line arguments to decide which nodes to iterate over - for each selected node, in "graph order":