From 0ab2a1f69791fd64750315bdede73efa434428c0 Mon Sep 17 00:00:00 2001 From: Anna Saiapina Date: Thu, 4 Jul 2024 14:39:43 +0000 Subject: [PATCH] Keeping both formatted and not time fields for calls --- definitions/staging/stg_calls.sqlx | 63 ++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/definitions/staging/stg_calls.sqlx b/definitions/staging/stg_calls.sqlx index 1d9242a..b27a514 100644 --- a/definitions/staging/stg_calls.sqlx +++ b/definitions/staging/stg_calls.sqlx @@ -25,39 +25,45 @@ select DAY_OF_WEEK, COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION, AGENT_NAME, ANI, + CALL_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, + ) as CALL_TIME_FORMATTED, + RING_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, + ) as RING_TIME_FORMATTED, + TALK_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, + ) as TALK_TIME_FORMATTED, + AFTER_CALL_WORK_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, + ) as AFTER_CALL_WORK_TIME_FORMATTED, ABANDONED, COALESCE(AGENT_GROUP, '0') AS AGENT_GROUP, CALLS, + SPEED_OF_ANSWER, 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 , + ) as SPEED_OF_ANSWER_FORMATTED, + TIME_TO_ABANDON, 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, + ) as TIME_TO_ABANDON_FORMATTED, TIMESTAMP, TIME_INTERVAL, ABANDON_RATE, @@ -91,59 +97,69 @@ select DAY_OF_WEEK, SESSION_ID, SIP_RESPONSE_CODE, SOA_MIN_THRESHOLD__sec_ SOA_MIN_THRESHOLD_SEC, + THIRD_PARTY_TALK_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, + ) as THIRD_PARTY_TALK_TIME_FORMATTED, + BILL_TIME__ROUNDED_ BILL_TIME_ROUNDED, 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, + ) as BILL_TIME_ROUNDED_FORMATTED, + CONFERENCE_TIME, 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, + ) as CONFERENCE_TIME_FORMATTED, 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, + ) as CONSULT_TIME_FORMATTED, COST, + DIAL_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, + ) as DIAL_TIME_FORMATTED, + HANDLE_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, + ) as HANDLE_TIME_FORMATTED, + HOLD_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, + ) as HOLD_TIME_FORMATTED, HOLDS, + IVR_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, + ) as IVR_TIME_FORMATTED, + MANUAL_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, + ) as MANUAL_TIME_FORMATTED, + PARK_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, + ) as PARK_TIME_FORMATTED, PARKS, PREVIEW_INTERRUPTED, PREVIEW_INTERRUPTED_BY_CALL, @@ -155,29 +171,33 @@ select DAY_OF_WEEK, ) as PREVIEW_TIME, QUEUE_CALLBACK_PROCESSING, QUEUE_CALLBACK_REGISTERED, + QUEUE_CALLBACK_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, + ) as QUEUE_CALLBACK_WAIT_TIME_FORMATTED, + QUEUE_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, + ) as QUEUE_WAIT_TIME_FORMATTED, 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, + ) as TOTAL_QUEUE_TIME_FORMATTED, 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, + ) as VIDEO_TIME_FORMATTED, AGENT, AGENT_EMAIL, AGENT_FIRST_NAME, @@ -231,11 +251,12 @@ 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, + ) as VOICEMAILS_HANDLE_TIME_FORMATTED, VOICEMAILS_HANDLED, VOICEMAILS_RETURNED_CALL, VOICEMAILS_TRANSFERRED,