Adding STATE field as a primary key

This commit is contained in:
Anna Saiapina 2024-09-18 14:40:15 +00:00 committed by GCP Dataform
parent 72fd1ffba5
commit 6bf5bc7037

View File

@ -1,10 +1,10 @@
config {
type: "incremental",
uniqueKey: ["AGENT_ID", "TIMESTAMP"],
uniqueKey: ["AGENT_ID", "TIMESTAMP", "STATE"],
schema: "pphe_five9_stg",
assertions: {
uniqueKey: ["AGENT_ID", "TIMESTAMP"],
nonNull: ["AGENT_ID", "TIMESTAMP"]
uniqueKey: ["AGENT_ID", "TIMESTAMP", "STATE"],
nonNull: ["AGENT_ID", "TIMESTAMP", "STATE"]
},
dependencies: ["agent_status_data_freshness"],
description: "All history data for agent status"
@ -14,7 +14,7 @@ config {
with agent_status_deduplicated as (
select *,
ROW_NUMBER()
OVER (PARTITION BY AGENT_ID, TIMESTAMP)
OVER (PARTITION BY AGENT_ID, TIMESTAMP, STATE)
row_number
from ${ref("pphe_five9_raw","agent_status_*")}
${ when(incremental(), `where _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) }) --last date table is taken