Add deduplication

This commit is contained in:
Anna Saiapina 2024-06-19 14:33:29 +00:00 committed by GCP Dataform
parent 16bf93a06c
commit ccb919db03

View File

@ -10,6 +10,13 @@ config {
description: "All history data for calls" description: "All history data for calls"
} }
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, select DAY_OF_WEEK,
CALL_ID, CALL_ID,
CAMPAIGN, CAMPAIGN,
@ -209,5 +216,5 @@ select DAY_OF_WEEK,
Social_Category SOCIAL_CATEGORY, Social_Category SOCIAL_CATEGORY,
Social_socialId SOCIAL_SOCIALID, Social_socialId SOCIAL_SOCIALID,
Studio_transfer_disposition STUDIO_TRANSFER_DISPOSITION Studio_transfer_disposition STUDIO_TRANSFER_DISPOSITION
from ${ref("calls_*")} from calls_deduplicated
${ when(incremental(), `where _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) } where row_number = 1