Same for digital

This commit is contained in:
Anna Saiapina 2024-07-04 14:26:44 +00:00 committed by GCP Dataform
parent 966b0c4615
commit bb96e38bf2

View File

@ -19,9 +19,21 @@ 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(
EMAIL_QUEUE_TIME, cast(time(timestamp_seconds(cast(RESPONSE_TIME as int))) as string),
HANDLE_TIME, 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)
) as RESPONSE_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(EMAIL_QUEUE_TIME as int))) as string),
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)
) as EMAIL_QUEUE_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(HANDLE_TIME as int))) as string),
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)
) as HANDLE_TIME,
TIMESTAMP, TIMESTAMP,
MEDIA_TYPE, MEDIA_TYPE,
TRANSFERS_TO_SKILL, TRANSFERS_TO_SKILL,
@ -34,7 +46,11 @@ 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(
cast(time(timestamp_seconds(cast(ASSIGNED_DURATION as int))) as string),
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)
) as ASSIGNED_DURATION,
CAMPAIGN, CAMPAIGN,
CHAT_QUESTION, CHAT_QUESTION,
EMAIL_SUBJECT, EMAIL_SUBJECT,
@ -59,33 +75,81 @@ select AGENT_NAME,
AFTER_CHAT_WORK, AFTER_CHAT_WORK,
AUTO_REQUEUE, AUTO_REQUEUE,
CHAT_ENGAGED, CHAT_ENGAGED,
CHAT_QUEUE_TIME, regexp_replace(
cast(time(timestamp_seconds(cast(CHAT_QUEUE_TIME as int))) as string),
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)
) as CHAT_QUEUE_TIME,
CHAT_REJECTED, CHAT_REJECTED,
CHAT_TIME, regexp_replace(
cast(time(timestamp_seconds(cast(CHAT_TIME as int))) as string),
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)
) as CHAT_TIME,
CHAT_WITHDRAWN, CHAT_WITHDRAWN,
DECISION_TIME, regexp_replace(
cast(time(timestamp_seconds(cast(DECISION_TIME as int))) as string),
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)
) as DECISION_TIME,
EMAIL_AUTO_REPLY, EMAIL_AUTO_REPLY,
EMAIL_AUTO_REPLY_FAILED, EMAIL_AUTO_REPLY_FAILED,
EMAIL_SERVER_TIME, EMAIL_SERVER_TIME,
EMAIL_TIME, regexp_replace(
FCR_TIME, cast(time(timestamp_seconds(cast(EMAIL_TIME as int))) as string),
INTERACTION_TIME, 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)
) as EMAIL_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(FCR_TIME as int))) as string),
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)
) as FCR_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(INTERACTION_TIME as int))) as string),
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)
) as INTERACTION_TIME,
PREVIEW_ENGAGED, PREVIEW_ENGAGED,
PREVIEW_TIME, regexp_replace(
cast(time(timestamp_seconds(cast(PREVIEW_TIME as int))) as string),
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)
) as PREVIEW_TIME,
PROACTIVE_CHAT_OFFER_ACCEPTED, PROACTIVE_CHAT_OFFER_ACCEPTED,
PROACTIVE_OFFERS, PROACTIVE_OFFERS,
PROGRESS_TIME, regexp_replace(
QUEUE_TIME, cast(time(timestamp_seconds(cast(PROGRESS_TIME as int))) as string),
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)
) as PROGRESS_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(QUEUE_TIME as int))) as string),
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)
) as QUEUE_TIME,
REJECT_BY_AGENT, REJECT_BY_AGENT,
RESOLUTION_TIME, regexp_replace(
cast(time(timestamp_seconds(cast(RESOLUTION_TIME as int))) as string),
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)
) as RESOLUTION_TIME,
SUPERVISOR_TRANSFERS, SUPERVISOR_TRANSFERS,
TIME_TILL_ACCEPT, regexp_replace(
cast(time(timestamp_seconds(cast(TIME_TILL_ACCEPT as int))) as string),
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)
) as TIME_TILL_ACCEPT,
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(
cast(time(timestamp_seconds(cast(VIDEO_TIME as int))) as string),
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)
) as VIDEO_TIME,
VIDEO_TOTAL_DURATION VIDEO_TOTAL_DURATION
from digital_deduplicated from digital_deduplicated
where row_number = 1 where row_number = 1