dbt Analytics Engineering (50 Qs)•Part 3: Enterprise Scale, Performance & CI/CD Pipelines (Senior / Staff)
How do you handle Late-Arriving Data in Incremental Models?
senior LevelMost AskedCode ExampleFormsPerformancePipes
In Simple Words:
If an order placed on Monday is held up by payment processing and arrives on Thursday, a naive incremental filter (WHERE updated_at > (SELECT MAX(updated_at) FROM {{ this }})) will completely miss the Monday record!
The Lookback Window Solution:
Subtract a safety window (e.g., 3 days) from the incremental filter to capture late-arriving dimensions:
sql
{% if is_incremental() %}
WHERE order_updated_at > (
SELECT DATEADD('day', -3, MAX(order_updated_at)) FROM {{ this }}
)
{% endif %}