Keeping both formatted and not time fields for calls

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

View File

@ -25,39 +25,45 @@ select DAY_OF_WEEK,
COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION, COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION,
AGENT_NAME, AGENT_NAME,
ANI, ANI,
CALL_TIME,
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',
cast(extract(hour from time(timestamp_seconds(cast(CALL_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CALL_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(CALL_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CALL_TIME as int)))) as string)
) as CALL_TIME, ) as CALL_TIME_FORMATTED,
RING_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(RING_TIME as int))) as string), cast(time(timestamp_seconds(cast(RING_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(RING_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(RING_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(RING_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(RING_TIME as int)))) as string)
) as RING_TIME, ) as RING_TIME_FORMATTED,
TALK_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(TALK_TIME as int))) as string), cast(time(timestamp_seconds(cast(TALK_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(TALK_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(TALK_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(TALK_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(TALK_TIME as int)))) as string)
) as TALK_TIME, ) as TALK_TIME_FORMATTED,
AFTER_CALL_WORK_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(AFTER_CALL_WORK_TIME as int))) as string), cast(time(timestamp_seconds(cast(AFTER_CALL_WORK_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(AFTER_CALL_WORK_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(AFTER_CALL_WORK_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(AFTER_CALL_WORK_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(AFTER_CALL_WORK_TIME as int)))) as string)
) as AFTER_CALL_WORK_TIME, ) as AFTER_CALL_WORK_TIME_FORMATTED,
ABANDONED, ABANDONED,
COALESCE(AGENT_GROUP, '0') AS AGENT_GROUP, COALESCE(AGENT_GROUP, '0') AS AGENT_GROUP,
CALLS, CALLS,
SPEED_OF_ANSWER,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(SPEED_OF_ANSWER as int))) as string), cast(time(timestamp_seconds(cast(SPEED_OF_ANSWER as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(SPEED_OF_ANSWER as int)))) + 24 * unix_date(date(timestamp_seconds(cast(SPEED_OF_ANSWER as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(SPEED_OF_ANSWER as int)))) + 24 * unix_date(date(timestamp_seconds(cast(SPEED_OF_ANSWER as int)))) as string)
) as SPEED_OF_ANSWER , ) as SPEED_OF_ANSWER_FORMATTED,
TIME_TO_ABANDON,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(TIME_TO_ABANDON as int))) as string), cast(time(timestamp_seconds(cast(TIME_TO_ABANDON as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(TIME_TO_ABANDON as int)))) + 24 * unix_date(date(timestamp_seconds(cast(TIME_TO_ABANDON as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(TIME_TO_ABANDON as int)))) + 24 * unix_date(date(timestamp_seconds(cast(TIME_TO_ABANDON as int)))) as string)
) as TIME_TO_ABANDON, ) as TIME_TO_ABANDON_FORMATTED,
TIMESTAMP, TIMESTAMP,
TIME_INTERVAL, TIME_INTERVAL,
ABANDON_RATE, ABANDON_RATE,
@ -91,59 +97,69 @@ select DAY_OF_WEEK,
SESSION_ID, SESSION_ID,
SIP_RESPONSE_CODE, SIP_RESPONSE_CODE,
SOA_MIN_THRESHOLD__sec_ SOA_MIN_THRESHOLD_SEC, SOA_MIN_THRESHOLD__sec_ SOA_MIN_THRESHOLD_SEC,
THIRD_PARTY_TALK_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(THIRD_PARTY_TALK_TIME as int))) as string), cast(time(timestamp_seconds(cast(THIRD_PARTY_TALK_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(THIRD_PARTY_TALK_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(THIRD_PARTY_TALK_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(THIRD_PARTY_TALK_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(THIRD_PARTY_TALK_TIME as int)))) as string)
) as THIRD_PARTY_TALK_TIME, ) as THIRD_PARTY_TALK_TIME_FORMATTED,
BILL_TIME__ROUNDED_ BILL_TIME_ROUNDED,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(BILL_TIME__ROUNDED_ as int))) as string), cast(time(timestamp_seconds(cast(BILL_TIME__ROUNDED_ as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(BILL_TIME__ROUNDED_ as int)))) + 24 * unix_date(date(timestamp_seconds(cast(BILL_TIME__ROUNDED_ as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(BILL_TIME__ROUNDED_ as int)))) + 24 * unix_date(date(timestamp_seconds(cast(BILL_TIME__ROUNDED_ as int)))) as string)
) as BILL_TIME_ROUNDED, ) as BILL_TIME_ROUNDED_FORMATTED,
CONFERENCE_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(CONFERENCE_TIME as int))) as string), cast(time(timestamp_seconds(cast(CONFERENCE_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(CONFERENCE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CONFERENCE_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(CONFERENCE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CONFERENCE_TIME as int)))) as string)
) as CONFERENCE_TIME, ) as CONFERENCE_TIME_FORMATTED,
CONFERENCES, CONFERENCES,
CONSULT_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(CONSULT_TIME as int))) as string), cast(time(timestamp_seconds(cast(CONSULT_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(CONSULT_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CONSULT_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(CONSULT_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(CONSULT_TIME as int)))) as string)
) as CONSULT_TIME, ) as CONSULT_TIME_FORMATTED,
COST, COST,
DIAL_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(DIAL_TIME as int))) as string), cast(time(timestamp_seconds(cast(DIAL_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(DIAL_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(DIAL_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(DIAL_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(DIAL_TIME as int)))) as string)
) as DIAL_TIME, ) as DIAL_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,
HOLD_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(HOLD_TIME as int))) as string), cast(time(timestamp_seconds(cast(HOLD_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(HOLD_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(HOLD_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(HOLD_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(HOLD_TIME as int)))) as string)
) as HOLD_TIME, ) as HOLD_TIME_FORMATTED,
HOLDS, HOLDS,
IVR_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(IVR_TIME as int))) as string), cast(time(timestamp_seconds(cast(IVR_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(IVR_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(IVR_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(IVR_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(IVR_TIME as int)))) as string)
) as IVR_TIME, ) as IVR_TIME_FORMATTED,
MANUAL_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(MANUAL_TIME as int))) as string), cast(time(timestamp_seconds(cast(MANUAL_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(MANUAL_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(MANUAL_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(MANUAL_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(MANUAL_TIME as int)))) as string)
) as MANUAL_TIME, ) as MANUAL_TIME_FORMATTED,
PARK_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(PARK_TIME as int))) as string), cast(time(timestamp_seconds(cast(PARK_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(PARK_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(PARK_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(PARK_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(PARK_TIME as int)))) as string)
) as PARK_TIME, ) as PARK_TIME_FORMATTED,
PARKS, PARKS,
PREVIEW_INTERRUPTED, PREVIEW_INTERRUPTED,
PREVIEW_INTERRUPTED_BY_CALL, PREVIEW_INTERRUPTED_BY_CALL,
@ -155,29 +171,33 @@ select DAY_OF_WEEK,
) as PREVIEW_TIME, ) as PREVIEW_TIME,
QUEUE_CALLBACK_PROCESSING, QUEUE_CALLBACK_PROCESSING,
QUEUE_CALLBACK_REGISTERED, QUEUE_CALLBACK_REGISTERED,
QUEUE_CALLBACK_WAIT_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(QUEUE_CALLBACK_WAIT_TIME as int))) as string), cast(time(timestamp_seconds(cast(QUEUE_CALLBACK_WAIT_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(QUEUE_CALLBACK_WAIT_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(QUEUE_CALLBACK_WAIT_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(QUEUE_CALLBACK_WAIT_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(QUEUE_CALLBACK_WAIT_TIME as int)))) as string)
) as QUEUE_CALLBACK_WAIT_TIME, ) as QUEUE_CALLBACK_WAIT_TIME_FORMATTED,
QUEUE_WAIT_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(QUEUE_WAIT_TIME as int))) as string), cast(time(timestamp_seconds(cast(QUEUE_WAIT_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(QUEUE_WAIT_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(QUEUE_WAIT_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(QUEUE_WAIT_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(QUEUE_WAIT_TIME as int)))) as string)
) as QUEUE_WAIT_TIME, ) as QUEUE_WAIT_TIME_FORMATTED,
RATE, RATE,
TALK_TIME_LESS_HOLD_AND_PARK, TALK_TIME_LESS_HOLD_AND_PARK,
TOTAL_QUEUE_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(TOTAL_QUEUE_TIME as int))) as string), cast(time(timestamp_seconds(cast(TOTAL_QUEUE_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(TOTAL_QUEUE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(TOTAL_QUEUE_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(TOTAL_QUEUE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(TOTAL_QUEUE_TIME as int)))) as string)
) as TOTAL_QUEUE_TIME, ) as TOTAL_QUEUE_TIME_FORMATTED,
TRANSFERS, TRANSFERS,
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,
AGENT, AGENT,
AGENT_EMAIL, AGENT_EMAIL,
AGENT_FIRST_NAME, AGENT_FIRST_NAME,
@ -231,11 +251,12 @@ select DAY_OF_WEEK,
VOICEMAILS, VOICEMAILS,
VOICEMAILS_DECLINED, VOICEMAILS_DECLINED,
VOICEMAILS_DELETED, VOICEMAILS_DELETED,
VOICEMAILS_HANDLE_TIME,
regexp_replace( regexp_replace(
cast(time(timestamp_seconds(cast(VOICEMAILS_HANDLE_TIME as int))) as string), cast(time(timestamp_seconds(cast(VOICEMAILS_HANDLE_TIME as int))) as string),
r'^\d\d', r'^\d\d',
cast(extract(hour from time(timestamp_seconds(cast(VOICEMAILS_HANDLE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(VOICEMAILS_HANDLE_TIME as int)))) as string) cast(extract(hour from time(timestamp_seconds(cast(VOICEMAILS_HANDLE_TIME as int)))) + 24 * unix_date(date(timestamp_seconds(cast(VOICEMAILS_HANDLE_TIME as int)))) as string)
) as VOICEMAILS_HANDLE_TIME, ) as VOICEMAILS_HANDLE_TIME_FORMATTED,
VOICEMAILS_HANDLED, VOICEMAILS_HANDLED,
VOICEMAILS_RETURNED_CALL, VOICEMAILS_RETURNED_CALL,
VOICEMAILS_TRANSFERRED, VOICEMAILS_TRANSFERRED,