Jinja templating is dbt's mechanism for adding programmatic logic — variables, conditionals, loops, and function calls — to SQL files that would otherwise be static strings. The two most important Jinja constructs in dbt are `ref()` and `source()`: `ref()` creates a cross-model dependency and resolves to the correct schema-qualified table name in any environment, and `source()` declares a dependency on a raw source table while enabling lineage tracking and freshness checks. Without these two functions, dbt would be a script runner rather than an intelligent transformation framework.
Jinja in dbt operates in two modes. `{{ expression }}` renders the result of the Jinja expression into the SQL string — `{{ ref('model') }}` becomes `"schema"."model"`. `{% statement %}` executes Jinja control flow without rendering output — `{% if is_incremental() %}` adds conditional logic without emitting any SQL at that point. `{# comment #}` adds Jinja comments that are stripped from the compiled SQL. Understanding which constructs render output and which execute logic is essential for writing Jinja templates that compile to correct SQL.
Analogy🏏Cricket
🏏 Think of it like cricket: Migrating from Airflow to Prefect is like the same bowling coach shifting from traditional Test cricket notation to a modern T20 analytics dashboard — the underlying ball-by-ball data (the business logic) is exactly the same. What changes is how the data is recorded, displayed, and acted upon. The yorker that Bumrah bowls in over 20 is identical whether it is recorded in the old scorebook (Airflow DAG file) or the new analytics platform (Prefect flow). The migration is a transcription exercise, not a strategy change — and a wise coach verifies that the runs, wickets, and economies match exactly between the old and new system before decommissioning the scorebook. That verification step is the whole heart of the migration: because the yorker is unchanged, the only honest test is to run the same over through both systems and confirm the recorded runs, wickets and economies match to the last digit before the old scorebook is thrown away. Rushing to burn the scorebook the moment the shiny dashboard lights up is how teams lose a season of records to a silent transcription slip. The coach keeps both systems running in parallel for a while, reconciles their outputs ball by ball, and only when every figure agrees does he trust the new dashboard alone — a transcription is only complete when you have proven nothing was lost in the copying.
🏏 Showing the Cricket analogy — a Cricket version isn’t available for this concept yet.