Same for digital

This commit is contained in:
Anna Saiapina 2024-07-04 14:43:58 +00:00 committed by GCP Dataform
parent 0ab2a1f697
commit e6285f8ee3

View File

@ -19,21 +19,24 @@ 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"))`) })
select AGENT_NAME, select AGENT_NAME,
COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION, COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION,
RESPONSE_TIME,
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',
cast(extract(hour from time(timestamp_seconds(cast(RESPONSE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(RESPONSE_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(RESPONSE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(RESPONSE_TIME as int)))) as string)
) as RESPONSE_TIME, ) as RESPONSE_TIME_FORMATTED,
EMAIL_QUEUE_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(EMAIL_QUEUE_TIME as int))) as string), cast(time(timestamp_seconds(cast(EMAIL_QUEUE_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(EMAIL_QUEUE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(EMAIL_QUEUE_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(EMAIL_QUEUE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(EMAIL_QUEUE_TIME as int)))) as string)
) as EMAIL_QUEUE_TIME, ) as EMAIL_QUEUE_TIME_FORMATTED,
HANDLE_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(HANDLE_TIME as int))) as string), cast(time(timestamp_seconds(cast(HANDLE_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(HANDLE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(HANDLE_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(HANDLE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(HANDLE_TIME as int)))) as string)
) as HANDLE_TIME, ) as HANDLE_TIME_FORMATTED,
TIMESTAMP, TIMESTAMP,
MEDIA_TYPE, MEDIA_TYPE,
TRANSFERS_TO_SKILL, TRANSFERS_TO_SKILL,
@ -46,11 +49,12 @@ select AGENT_NAME,
AGENT_FIRST_NAME, AGENT_FIRST_NAME,
AGENT_ID, AGENT_ID,
COALESCE(AGENT_GROUP, '0') AS AGENT_GROUP, COALESCE(AGENT_GROUP, '0') AS AGENT_GROUP,
ASSIGNED_DURATION,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(ASSIGNED_DURATION as int))) as string), cast(time(timestamp_seconds(cast(ASSIGNED_DURATION as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(ASSIGNED_DURATION as int)))) + 24 * unix_date(date(timestamp_seconds(cast(ASSIGNED_DURATION as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(ASSIGNED_DURATION as int)))) + 24 * unix_date(date(timestamp_seconds(cast(ASSIGNED_DURATION as int)))) as string)
) as ASSIGNED_DURATION, ) as ASSIGNED_DURATION_FORMATTED,
CAMPAIGN, CAMPAIGN,
CHAT_QUESTION, CHAT_QUESTION,
EMAIL_SUBJECT, EMAIL_SUBJECT,
@ -75,81 +79,93 @@ select AGENT_NAME,
AFTER_CHAT_WORK, AFTER_CHAT_WORK,
AUTO_REQUEUE, AUTO_REQUEUE,
CHAT_ENGAGED, CHAT_ENGAGED,
CHAT_QUEUE_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(CHAT_QUEUE_TIME as int))) as string), cast(time(timestamp_seconds(cast(CHAT_QUEUE_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(CHAT_QUEUE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CHAT_QUEUE_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(CHAT_QUEUE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CHAT_QUEUE_TIME as int)))) as string)
) as CHAT_QUEUE_TIME, ) as CHAT_QUEUE_TIME_FORMATTED,
CHAT_REJECTED, CHAT_REJECTED,
CHAT_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(CHAT_TIME as int))) as string), cast(time(timestamp_seconds(cast(CHAT_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(CHAT_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CHAT_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(CHAT_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CHAT_TIME as int)))) as string)
) as CHAT_TIME, ) as CHAT_TIME_FORMATTED,
CHAT_WITHDRAWN, CHAT_WITHDRAWN,
DECISION_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(DECISION_TIME as int))) as string), cast(time(timestamp_seconds(cast(DECISION_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(DECISION_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(DECISION_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(DECISION_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(DECISION_TIME as int)))) as string)
) as DECISION_TIME, ) as DECISION_TIME_FORMATTED,
EMAIL_AUTO_REPLY, EMAIL_AUTO_REPLY,
EMAIL_AUTO_REPLY_FAILED, EMAIL_AUTO_REPLY_FAILED,
EMAIL_SERVER_TIME, EMAIL_SERVER_TIME,
EMAIL_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(EMAIL_TIME as int))) as string), cast(time(timestamp_seconds(cast(EMAIL_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(EMAIL_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(EMAIL_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(EMAIL_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(EMAIL_TIME as int)))) as string)
) as EMAIL_TIME, ) as EMAIL_TIME_FORMATTED,
FCR_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(FCR_TIME as int))) as string), cast(time(timestamp_seconds(cast(FCR_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(FCR_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(FCR_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(FCR_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(FCR_TIME as int)))) as string)
) as FCR_TIME, ) as FCR_TIME_FORMATTED,
INTERACTION_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(INTERACTION_TIME as int))) as string), cast(time(timestamp_seconds(cast(INTERACTION_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(INTERACTION_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(INTERACTION_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(INTERACTION_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(INTERACTION_TIME as int)))) as string)
) as INTERACTION_TIME, ) as INTERACTION_TIME_FORMATTED,
PREVIEW_ENGAGED, PREVIEW_ENGAGED,
PREVIEW_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(PREVIEW_TIME as int))) as string), cast(time(timestamp_seconds(cast(PREVIEW_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(PREVIEW_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(PREVIEW_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(PREVIEW_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(PREVIEW_TIME as int)))) as string)
) as PREVIEW_TIME, ) as PREVIEW_TIME_FORMATTED,
PROACTIVE_CHAT_OFFER_ACCEPTED, PROACTIVE_CHAT_OFFER_ACCEPTED,
PROACTIVE_OFFERS, PROACTIVE_OFFERS,
PROGRESS_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(PROGRESS_TIME as int))) as string), cast(time(timestamp_seconds(cast(PROGRESS_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(PROGRESS_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(PROGRESS_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(PROGRESS_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(PROGRESS_TIME as int)))) as string)
) as PROGRESS_TIME, ) as PROGRESS_TIME_FORMATTED,
QUEUE_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(QUEUE_TIME as int))) as string), cast(time(timestamp_seconds(cast(QUEUE_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(QUEUE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(QUEUE_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(QUEUE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(QUEUE_TIME as int)))) as string)
) as QUEUE_TIME, ) as QUEUE_TIME_FORMATTED,
REJECT_BY_AGENT, REJECT_BY_AGENT,
RESOLUTION_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(RESOLUTION_TIME as int))) as string), cast(time(timestamp_seconds(cast(RESOLUTION_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(RESOLUTION_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(RESOLUTION_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(RESOLUTION_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(RESOLUTION_TIME as int)))) as string)
) as RESOLUTION_TIME, ) as RESOLUTION_TIME_FORMATTED,
SUPERVISOR_TRANSFERS, SUPERVISOR_TRANSFERS,
TIME_TILL_ACCEPT,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(TIME_TILL_ACCEPT as int))) as string), cast(time(timestamp_seconds(cast(TIME_TILL_ACCEPT as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(TIME_TILL_ACCEPT as int)))) + 24 * unix_date(date(timestamp_seconds(cast(TIME_TILL_ACCEPT as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(TIME_TILL_ACCEPT as int)))) + 24 * unix_date(date(timestamp_seconds(cast(TIME_TILL_ACCEPT as int)))) as string)
) as TIME_TILL_ACCEPT, ) as TIME_TILL_ACCEPT_FORMATTED,
TRANSFERS, TRANSFERS,
VIDEO_FIRST_DURATION, VIDEO_FIRST_DURATION,
VIDEO_INTERACTIONS, VIDEO_INTERACTIONS,
VIDEO_INTERACTIONS_No__of_Times VIDEO_INTERACTIONS_NO_OF_TIMES, VIDEO_INTERACTIONS_No__of_Times VIDEO_INTERACTIONS_NO_OF_TIMES,
VIDEO_SECOND_DURATION, VIDEO_SECOND_DURATION,
VIDEO_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(VIDEO_TIME as int))) as string), cast(time(timestamp_seconds(cast(VIDEO_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(VIDEO_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(VIDEO_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(VIDEO_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(VIDEO_TIME as int)))) as string)
) as VIDEO_TIME, ) as VIDEO_TIME_FORMATTED,
VIDEO_TOTAL_DURATION VIDEO_TOTAL_DURATION
from digital_deduplicated from digital_deduplicated
where row_number = 1 where row_number = 1