Add time fields conversion

This commit is contained in:
Anna Saiapina 2024-07-04 14:14:58 +00:00 committed by GCP Dataform
parent 3e37926450
commit 966b0c4615

View File

@ -25,15 +25,39 @@ select DAY_OF_WEEK,
COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION,
AGENT_NAME,
ANI,
CALL_TIME,
RING_TIME,
TALK_TIME,
AFTER_CALL_WORK_TIME,--
regexp_replace(
cast(time(timestamp_seconds(cast(CALL_TIME as int))) as string),
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)
) as CALL_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(RING_TIME as int))) as string),
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)
) as RING_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(TALK_TIME as int))) as string),
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)
) as TALK_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(AFTER_CALL_WORK_TIME as int))) as string),
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)
) as AFTER_CALL_WORK_TIME,
ABANDONED,
COALESCE(AGENT_GROUP, '0') AS AGENT_GROUP,
CALLS,
SPEED_OF_ANSWER ,
TIME_TO_ABANDON,
regexp_replace(
cast(time(timestamp_seconds(cast(SPEED_OF_ANSWER as int))) as string),
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)
) as SPEED_OF_ANSWER ,
regexp_replace(
cast(time(timestamp_seconds(cast(TIME_TO_ABANDON as int))) as string),
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)
) as TIME_TO_ABANDON,
TIMESTAMP,
TIME_INTERVAL,
ABANDON_RATE,
@ -67,33 +91,93 @@ select DAY_OF_WEEK,
SESSION_ID,
SIP_RESPONSE_CODE,
SOA_MIN_THRESHOLD__sec_ SOA_MIN_THRESHOLD_SEC,
THIRD_PARTY_TALK_TIME,
BILL_TIME__ROUNDED_ BILL_TIME_ROUNDED,
CONFERENCE_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(THIRD_PARTY_TALK_TIME as int))) as string),
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)
) as THIRD_PARTY_TALK_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(BILL_TIME__ROUNDED_ as int))) as string),
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)
) as BILL_TIME_ROUNDED,
regexp_replace(
cast(time(timestamp_seconds(cast(CONFERENCE_TIME as int))) as string),
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)
) as CONFERENCE_TIME,
CONFERENCES,
CONSULT_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(CONSULT_TIME as int))) as string),
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)
) as CONSULT_TIME,
COST,
DIAL_TIME,
HANDLE_TIME,
HOLD_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(DIAL_TIME as int))) as string),
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)
) as DIAL_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,
regexp_replace(
cast(time(timestamp_seconds(cast(HOLD_TIME as int))) as string),
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)
) as HOLD_TIME,
HOLDS,
IVR_TIME,
MANUAL_TIME,
PARK_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(IVR_TIME as int))) as string),
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)
) as IVR_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(MANUAL_TIME as int))) as string),
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)
) as MANUAL_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(PARK_TIME as int))) as string),
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)
) as PARK_TIME,
PARKS,
PREVIEW_INTERRUPTED,
PREVIEW_INTERRUPTED_BY_CALL,
PREVIEW_INTERRUPTED_BY_SKILL_VM,
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,
QUEUE_CALLBACK_PROCESSING,
QUEUE_CALLBACK_REGISTERED,
QUEUE_CALLBACK_WAIT_TIME,
QUEUE_WAIT_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(QUEUE_CALLBACK_WAIT_TIME as int))) as string),
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)
) as QUEUE_CALLBACK_WAIT_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(QUEUE_WAIT_TIME as int))) as string),
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)
) as QUEUE_WAIT_TIME,
RATE,
TALK_TIME_LESS_HOLD_AND_PARK,
TOTAL_QUEUE_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(TOTAL_QUEUE_TIME as int))) as string),
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)
) as TOTAL_QUEUE_TIME,
TRANSFERS,
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,
AGENT,
AGENT_EMAIL,
AGENT_FIRST_NAME,
@ -147,7 +231,11 @@ select DAY_OF_WEEK,
VOICEMAILS,
VOICEMAILS_DECLINED,
VOICEMAILS_DELETED,
VOICEMAILS_HANDLE_TIME,
regexp_replace(
cast(time(timestamp_seconds(cast(VOICEMAILS_HANDLE_TIME as int))) as string),
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)
) as VOICEMAILS_HANDLE_TIME,
VOICEMAILS_HANDLED,
VOICEMAILS_RETURNED_CALL,
VOICEMAILS_TRANSFERRED,