Jinja is a templating language. In dbt, your .sql files are templates that compile into plain SQL before the warehouse executes them.
What Jinja enables
ref()/source()resolutionconfig(),is_incremental(),{{ this }}{% if %}, loops, macros- Environment-aware SQL without maintaining five copies of a query
Example
select *
from {{ ref('stg_orders') }}
{% if var('exclude_test_orders', true) %}
where is_test = false
{% endif %}Compiled SQL has no Jinja left; the warehouse only sees SQL.
Mental model
model.sql (SQL + Jinja)
|
dbt compile
|
target/compiled/.../*.sql (pure SQL)
|
warehouse executesDebugging tip
Use dbt compile --select model and read target/compiled when Jinja behavior is confusing.
Interview tip: "Jinja is compile-time. Heavy procedural logic belongs in macros carefully; the warehouse still does the data processing."