Add deduplication to digital stg table

This commit is contained in:
Anna Saiapina 2024-06-24 13:55:25 +00:00 committed by GCP Dataform
parent ae11ad5f6b
commit 2e58b02e5e

View File

@ -10,6 +10,13 @@ config {
description: "All history data for digital"
}
with digital_deduplicated as (
select *,
ROW_NUMBER()
OVER (PARTITION BY SESSION_GUID)
row_number
from ${ref("pphe_five9_raw","digital_*")}
${ when(incremental(), `where _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) })
select AGENT_NAME,
DISPOSITION,
RESPONSE_TIME,
@ -80,5 +87,5 @@ select AGENT_NAME,
VIDEO_SECOND_DURATION,
VIDEO_TIME,
VIDEO_TOTAL_DURATION
from ${ref("digital_*")}
${ when(incremental(), `where _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) }
from digital_deduplicated
where row_number = 1