diff --git a/definitions/staging/stg_calls.sqlx b/definitions/staging/stg_calls.sqlx index fa10de8..b9ee5c2 100644 --- a/definitions/staging/stg_calls.sqlx +++ b/definitions/staging/stg_calls.sqlx @@ -9,8 +9,15 @@ config { tags: ["calls"], description: "All history data for calls" } - -select DAY_OF_WEEK, + +with calls_deduplicated as ( +select *, + ROW_NUMBER() + OVER (PARTITION BY SESSION_ID, TIMESTAMP, DNIS) + row_number +from ${ref("calls_*")} +${ when(incremental(), `where _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) }) +select DAY_OF_WEEK, CALL_ID, CAMPAIGN, SKILL, @@ -209,5 +216,5 @@ select DAY_OF_WEEK, Social_Category SOCIAL_CATEGORY, Social_socialId SOCIAL_SOCIALID, Studio_transfer_disposition STUDIO_TRANSFER_DISPOSITION -from ${ref("calls_*")} -${ when(incremental(), `where _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) } \ No newline at end of file +from calls_deduplicated +where row_number = 1 \ No newline at end of file