Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Incremental without unique_key

dbt · Incremental Models & Performance

Incremental without unique_key

Mediumdbt-22
unique_keyincrementalduplicates

Question

What happens if you run an incremental model without a unique_key?

Solution

Without a unique_key, dbt typically cannot safely upsert. Many adapters fall back to an append-only behavior: each incremental run inserts the filtered batch as new rows.

Consequences

Run 1: load orders for day D
Run 2: filter wrong / overlap → insert same order_ids again
Result: duplicate grain rows in the table

When no unique_key is OK

  • Truly append-only event streams
  • Your is_incremental() filter guarantees disjoint batches (e.g. strict watermark with no late data)
  • You accept duplicates and dedupe in a downstream model

When you need unique_key

  • Source rows can be updated (updated_at changes)
  • Late data can reappear for an old key
  • Consumers expect one row per business key
{{ config(
    materialized='incremental',
    unique_key='order_id',
    incremental_strategy='merge'
) }}

Interview tip: "No unique_key means I am betting on append-only semantics. If updates or late arrivals exist, I need a key and a merge/delete strategy."

PreviousNext