Comments for tables are added
This commit is contained in:
parent
67e6ffb93b
commit
106247b185
@ -9,6 +9,11 @@ config {
|
||||
description: "All fields that are connected to the AGENT"
|
||||
}
|
||||
|
||||
/*
|
||||
Originally AGENT_NAME field contains both name and languages of the agent.
|
||||
They can be divined by different variations of signs. Next 2 subqueries extract AGENT_NAME and LANGUAGES
|
||||
into 2 different fields for calls and digital data.
|
||||
*/
|
||||
with agent_digital as (
|
||||
select AGENT_ID,
|
||||
case
|
||||
@ -61,12 +66,13 @@ agent_calls as (
|
||||
timestamp
|
||||
from ${ref("stg_calls")}
|
||||
),
|
||||
-- Union of the agents for digital and calls
|
||||
all_agents as (
|
||||
select * from agent_digital
|
||||
union distinct
|
||||
select * from agent_calls
|
||||
),
|
||||
|
||||
-- Deduplication by AGENT_ID and Timestamp. It is necessary because agent characteristics can change over time
|
||||
all_agents_dedup as(
|
||||
select *,
|
||||
ROW_NUMBER ()
|
||||
@ -74,7 +80,7 @@ all_agents_dedup as(
|
||||
from all_agents
|
||||
|
||||
)
|
||||
|
||||
-- Add of the codes and ids with mapings
|
||||
select all_agents_dedup.AGENT_ID,
|
||||
all_agents_dedup.AGENT_NAME,
|
||||
all_agents_dedup.LANGUAGES,
|
||||
|
||||
@ -9,7 +9,8 @@ config {
|
||||
dependencies: ["calls_data_freshness"],
|
||||
description: "All history data for calls"
|
||||
}
|
||||
|
||||
|
||||
--Filter out abandoned calls and numerates by key for deduplication
|
||||
with calls_deduplicated as (
|
||||
select *,
|
||||
ROW_NUMBER()
|
||||
@ -17,7 +18,7 @@ select *,
|
||||
row_number
|
||||
from ${ref("pphe_five9_raw","calls_*")}
|
||||
where ABANDONED is not null
|
||||
${ when(incremental(), `and _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) })
|
||||
${ when(incremental(), `and _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) }) --last date table is taken
|
||||
select DAY_OF_WEEK,
|
||||
CALL_ID,
|
||||
CAMPAIGN,
|
||||
@ -26,6 +27,7 @@ select DAY_OF_WEEK,
|
||||
AGENT_NAME,
|
||||
ANI,
|
||||
CALL_TIME,
|
||||
--time data is loaded in seconds. Extra columns for times in formt hh:mm:ss are added
|
||||
regexp_replace(
|
||||
cast(time(timestamp_seconds(cast(CALL_TIME as int))) as string),
|
||||
r'^\d\d',
|
||||
|
||||
@ -12,6 +12,7 @@ config {
|
||||
description: "Main calls data for history report"
|
||||
}
|
||||
|
||||
--Extraction and transformation of fields that are used in Board load further. Contains all history data
|
||||
select sc.SESSION_ID,
|
||||
sc.DNIS,
|
||||
sc.TIMESTAMP,
|
||||
@ -25,7 +26,7 @@ select sc.SESSION_ID,
|
||||
case
|
||||
when sc.ROUTING_HOTEL_NAME is null
|
||||
then '_'
|
||||
else ifnull(p.BOARD_PROPERTY_GROUP, 'ADD')
|
||||
else ifnull(p.BOARD_PROPERTY_GROUP, 'ADD') --for check of the missed properties
|
||||
end BOARD_PROPERTY_GROUP,
|
||||
sc.AGENT_ID,
|
||||
sc.AGENT_NAME,
|
||||
|
||||
@ -15,6 +15,7 @@ config {
|
||||
description: "Main calls data for report"
|
||||
}
|
||||
|
||||
--Extraction and transformation of fields that are used in Board load further. Contains last 7 days
|
||||
select sc.SESSION_ID,
|
||||
sc.DNIS,
|
||||
sc.TIMESTAMP,
|
||||
@ -28,7 +29,7 @@ select sc.SESSION_ID,
|
||||
case
|
||||
when sc.ROUTING_HOTEL_NAME is null
|
||||
then '_'
|
||||
else ifnull(p.BOARD_PROPERTY_GROUP, 'ADD')
|
||||
else ifnull(p.BOARD_PROPERTY_GROUP, 'ADD') --for check of the missed properties
|
||||
end BOARD_PROPERTY_GROUP,
|
||||
sc.AGENT_ID,
|
||||
sc.AGENT_NAME,
|
||||
|
||||
@ -10,16 +10,18 @@ config {
|
||||
description: "All history data for digital"
|
||||
}
|
||||
|
||||
--Numerates by key for deduplication
|
||||
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"))`) })
|
||||
${ when(incremental(), `where _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) }) --last date table is taken
|
||||
select AGENT_NAME,
|
||||
COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION,
|
||||
RESPONSE_TIME,
|
||||
--time data is loaded in seconds. Extra columns for times in formt hh:mm:ss are added
|
||||
regexp_replace(
|
||||
cast(time(timestamp_seconds(cast(RESPONSE_TIME as int))) as string),
|
||||
r'^\d\d',
|
||||
|
||||
@ -11,7 +11,7 @@ config {
|
||||
description: "Main digital history data for report"
|
||||
}
|
||||
|
||||
|
||||
--Extraction and transformation of fields that are used in Board load further. Contains all history data
|
||||
select d.SESSION_GUID,
|
||||
d.TIMESTAMP,
|
||||
date(d.TIMESTAMP) DATE,
|
||||
|
||||
@ -11,6 +11,7 @@ config {
|
||||
description: "Main digital data for report"
|
||||
}
|
||||
|
||||
--Extraction and transformation of fields that are used in Board load further. Contains last 7 days
|
||||
select d.SESSION_GUID,
|
||||
d.TIMESTAMP,
|
||||
date(d.TIMESTAMP) DATE,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user