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"
|
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 (
|
with agent_digital as (
|
||||||
select AGENT_ID,
|
select AGENT_ID,
|
||||||
case
|
case
|
||||||
@ -61,12 +66,13 @@ agent_calls as (
|
|||||||
timestamp
|
timestamp
|
||||||
from ${ref("stg_calls")}
|
from ${ref("stg_calls")}
|
||||||
),
|
),
|
||||||
|
-- Union of the agents for digital and calls
|
||||||
all_agents as (
|
all_agents as (
|
||||||
select * from agent_digital
|
select * from agent_digital
|
||||||
union distinct
|
union distinct
|
||||||
select * from agent_calls
|
select * from agent_calls
|
||||||
),
|
),
|
||||||
|
-- Deduplication by AGENT_ID and Timestamp. It is necessary because agent characteristics can change over time
|
||||||
all_agents_dedup as(
|
all_agents_dedup as(
|
||||||
select *,
|
select *,
|
||||||
ROW_NUMBER ()
|
ROW_NUMBER ()
|
||||||
@ -74,7 +80,7 @@ all_agents_dedup as(
|
|||||||
from all_agents
|
from all_agents
|
||||||
|
|
||||||
)
|
)
|
||||||
|
-- Add of the codes and ids with mapings
|
||||||
select all_agents_dedup.AGENT_ID,
|
select all_agents_dedup.AGENT_ID,
|
||||||
all_agents_dedup.AGENT_NAME,
|
all_agents_dedup.AGENT_NAME,
|
||||||
all_agents_dedup.LANGUAGES,
|
all_agents_dedup.LANGUAGES,
|
||||||
|
|||||||
@ -9,7 +9,8 @@ config {
|
|||||||
dependencies: ["calls_data_freshness"],
|
dependencies: ["calls_data_freshness"],
|
||||||
description: "All history data for calls"
|
description: "All history data for calls"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--Filter out abandoned calls and numerates by key for deduplication
|
||||||
with calls_deduplicated as (
|
with calls_deduplicated as (
|
||||||
select *,
|
select *,
|
||||||
ROW_NUMBER()
|
ROW_NUMBER()
|
||||||
@ -17,7 +18,7 @@ select *,
|
|||||||
row_number
|
row_number
|
||||||
from ${ref("pphe_five9_raw","calls_*")}
|
from ${ref("pphe_five9_raw","calls_*")}
|
||||||
where ABANDONED is not null
|
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,
|
select DAY_OF_WEEK,
|
||||||
CALL_ID,
|
CALL_ID,
|
||||||
CAMPAIGN,
|
CAMPAIGN,
|
||||||
@ -26,6 +27,7 @@ select DAY_OF_WEEK,
|
|||||||
AGENT_NAME,
|
AGENT_NAME,
|
||||||
ANI,
|
ANI,
|
||||||
CALL_TIME,
|
CALL_TIME,
|
||||||
|
--time data is loaded in seconds. Extra columns for times in formt hh:mm:ss are added
|
||||||
regexp_replace(
|
regexp_replace(
|
||||||
cast(time(timestamp_seconds(cast(CALL_TIME as int))) as string),
|
cast(time(timestamp_seconds(cast(CALL_TIME as int))) as string),
|
||||||
r'^\d\d',
|
r'^\d\d',
|
||||||
|
|||||||
@ -12,6 +12,7 @@ config {
|
|||||||
description: "Main calls data for history report"
|
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,
|
select sc.SESSION_ID,
|
||||||
sc.DNIS,
|
sc.DNIS,
|
||||||
sc.TIMESTAMP,
|
sc.TIMESTAMP,
|
||||||
@ -25,7 +26,7 @@ select sc.SESSION_ID,
|
|||||||
case
|
case
|
||||||
when sc.ROUTING_HOTEL_NAME is null
|
when sc.ROUTING_HOTEL_NAME is null
|
||||||
then '_'
|
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,
|
end BOARD_PROPERTY_GROUP,
|
||||||
sc.AGENT_ID,
|
sc.AGENT_ID,
|
||||||
sc.AGENT_NAME,
|
sc.AGENT_NAME,
|
||||||
|
|||||||
@ -15,6 +15,7 @@ config {
|
|||||||
description: "Main calls data for report"
|
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,
|
select sc.SESSION_ID,
|
||||||
sc.DNIS,
|
sc.DNIS,
|
||||||
sc.TIMESTAMP,
|
sc.TIMESTAMP,
|
||||||
@ -28,7 +29,7 @@ select sc.SESSION_ID,
|
|||||||
case
|
case
|
||||||
when sc.ROUTING_HOTEL_NAME is null
|
when sc.ROUTING_HOTEL_NAME is null
|
||||||
then '_'
|
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,
|
end BOARD_PROPERTY_GROUP,
|
||||||
sc.AGENT_ID,
|
sc.AGENT_ID,
|
||||||
sc.AGENT_NAME,
|
sc.AGENT_NAME,
|
||||||
|
|||||||
@ -10,16 +10,18 @@ config {
|
|||||||
description: "All history data for digital"
|
description: "All history data for digital"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--Numerates by key for deduplication
|
||||||
with digital_deduplicated as (
|
with digital_deduplicated as (
|
||||||
select *,
|
select *,
|
||||||
ROW_NUMBER()
|
ROW_NUMBER()
|
||||||
OVER (PARTITION BY SESSION_GUID)
|
OVER (PARTITION BY SESSION_GUID)
|
||||||
row_number
|
row_number
|
||||||
from ${ref("pphe_five9_raw","digital_*")}
|
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,
|
select AGENT_NAME,
|
||||||
COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION,
|
COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION,
|
||||||
RESPONSE_TIME,
|
RESPONSE_TIME,
|
||||||
|
--time data is loaded in seconds. Extra columns for times in formt hh:mm:ss are added
|
||||||
regexp_replace(
|
regexp_replace(
|
||||||
cast(time(timestamp_seconds(cast(RESPONSE_TIME as int))) as string),
|
cast(time(timestamp_seconds(cast(RESPONSE_TIME as int))) as string),
|
||||||
r'^\d\d',
|
r'^\d\d',
|
||||||
|
|||||||
@ -11,7 +11,7 @@ config {
|
|||||||
description: "Main digital history data for report"
|
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,
|
select d.SESSION_GUID,
|
||||||
d.TIMESTAMP,
|
d.TIMESTAMP,
|
||||||
date(d.TIMESTAMP) DATE,
|
date(d.TIMESTAMP) DATE,
|
||||||
|
|||||||
@ -11,6 +11,7 @@ config {
|
|||||||
description: "Main digital data for report"
|
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,
|
select d.SESSION_GUID,
|
||||||
d.TIMESTAMP,
|
d.TIMESTAMP,
|
||||||
date(d.TIMESTAMP) DATE,
|
date(d.TIMESTAMP) DATE,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user