dbt incremental model ap kreye duplicate records

asked 2 days ago9 viewsen

0

Mwen gen yon dbt incremental model ki ap chaje done chak jou nan Snowflake. Men apre plizyè jou, mwen remake menm records yo parèt plizyè fwa nan destination table la.

What I tried

Mwen mete unique_key='transaction_id', men duplicate yo toujou ap parèt.
 
{{ config(
    materialized='incremental',
    unique_key='transaction_id'
) }}
 
SELECT
    transaction_id,
    customer_id,
    amount,
    transaction_date
FROM {{ source('sales', 'transactions') }}
 
{% if is_incremental() %}
WHERE transaction_date >= (
    SELECT MAX(transaction_date)
    FROM {{ this }}
)
{% endif %}

Error message

transaction_id | count
---------------|------
10001          | 3
10002          | 2
10003          | 4

Expected result

Chak transaction_id ta dwe parèt sèlman yon sèl fwa nan final table la.

Environment:dbt,snowflake dbt 1.10SnowflakeWindows 11

🤖 AI diagnosis

AI-generated. Not an answer — the community below confirms or corrects it. Always verify before relying on it.

No Answers

Sign in and verify your email to post an answer.