diff --git a/definitions/staging/stg_digital.sqlx b/definitions/staging/stg_digital.sqlx index 2fb97d1..a83849b 100644 --- a/definitions/staging/stg_digital.sqlx +++ b/definitions/staging/stg_digital.sqlx @@ -19,9 +19,21 @@ from ${ref("pphe_five9_raw","digital_*")} ${ when(incremental(), `where _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',current_date("Europe/Amsterdam"))`) }) select AGENT_NAME, COALESCE(DISPOSITION, '[Not Defined]') AS DISPOSITION, - RESPONSE_TIME, - EMAIL_QUEUE_TIME, - HANDLE_TIME, + regexp_replace( + cast(time(timestamp_seconds(cast(RESPONSE_TIME as int))) as string), + 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, MEDIA_TYPE, TRANSFERS_TO_SKILL, @@ -34,7 +46,11 @@ select AGENT_NAME, AGENT_FIRST_NAME, AGENT_ID, 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, CHAT_QUESTION, EMAIL_SUBJECT, @@ -59,33 +75,81 @@ select AGENT_NAME, AFTER_CHAT_WORK, AUTO_REQUEUE, 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_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, - 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_FAILED, EMAIL_SERVER_TIME, - EMAIL_TIME, - FCR_TIME, - INTERACTION_TIME, + regexp_replace( + cast(time(timestamp_seconds(cast(EMAIL_TIME as int))) as string), + 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_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_OFFERS, - PROGRESS_TIME, - QUEUE_TIME, + regexp_replace( + 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, - 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, - 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, VIDEO_FIRST_DURATION, VIDEO_INTERACTIONS, VIDEO_INTERACTIONS_No__of_Times VIDEO_INTERACTIONS_NO_OF_TIMES, 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 from digital_deduplicated where row_number = 1 \ No newline at end of file