dbt incremental model ap kreye duplicate records

poze 2 days ago6 gadeen

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.

Anviwònman:dbt,snowflake dbt 1.10SnowflakeWindows 11

🤖 Dyagnostik IA

Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.

Pa gen repons

Sign in and verify your email to post an answer.