Merged PR 2167: Survey to Staging

Brings the CSAT response table from the backend to staging area.

Related work items: #16947
This commit is contained in:
Pablo Martín 2024-07-01 15:02:10 +00:00
commit 28917fcc08
3 changed files with 32 additions and 0 deletions

View file

@ -213,3 +213,5 @@ sources:
identifier: Country
- name: VerificationSet
identifier: VerificationSet
- name: GuestSatisfaction
identifier: GuestSatisfaction

View file

@ -127,3 +127,10 @@ models:
tests:
- unique
- not_null
- name: stg_core__guest_satisfaction_responses
columns:
- name: id_verification_request
tests:
- unique
- not_null

View file

@ -0,0 +1,23 @@
{{ config(materialized="incremental", unique_key="id_verification_request") }}
with
raw_guest_satisfaction as (select * from {{ source("core", "GuestSatisfaction") }}),
stg_core__guest_satisfaction_responses as (
select
{{ adapter.quote("VerificationRequestId") }} as id_verification_request,
{{ adapter.quote("ExperienceRating") }} as experience_rating,
{{ adapter.quote("IsContactable") }} as is_contactable,
{{ adapter.quote("Comments") }} as guest_comments,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_guest_satisfaction
)
select *
from stg_core__guest_satisfaction_responses
{% if is_incremental() %}
where
updated_at_utc
>= ((select max(updated_at_utc) from {{ this }}) - interval '7 days')
{% endif %}