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 %}