Compile fork · 1st build ↔ 2nd+
is_incremental() = false scans ~128M rows creates fct_trips
Model (Jinja — same file both runs)
1{{
2 config(
3 materialized='incremental',
4 incremental_strategy='merge',
5 unique_key='trip_id'
6 )
7}}
8
9select t.trip_id, t.pickup_datetime, …
10from {{ ref('stg_trips') }} t
11left join {{ ref('stg_zones') }} pz …
12
On this run the guard is false — Jinja deletes the block before SQL reaches the warehouse.
On this run the guard is true — the where survives into compiled SQL.
13{% if is_incremental() %}
14 -- only trips newer than what we already have
15 where t.pickup_datetime > (
16 select max(pickup_datetime) from {{ this }}
17 )
18{% endif %}
Compiled SQL (what the warehouse runs)
1-- is_incremental() was false → no WHERE
2select t.trip_id, t.pickup_datetime, …
3from hyf.dev_yourname.stg_trips t
4left join hyf.dev_yourname.stg_zones pz …
5
6-- (filter block compiled away)
Key takeaway
Same model file. First build: table missing → is_incremental() = false → filter deleted → full scan.