Modified how stg_core__booking was being called and some typo errors
This commit is contained in:
parent
c4fc81d934
commit
6cb06b73cd
1 changed files with 6 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
{{ config(materialized="table", unique_key="id_booking") }}
|
||||
with
|
||||
stg_core__booking as (select * from {{ ref("stg_core__booking") }}),
|
||||
stg_core__booking_with_dup_flag as (
|
||||
select
|
||||
-- This ugly thing below is true if the booking is duplicate and is not
|
||||
|
|
@ -15,9 +16,9 @@ with
|
|||
else false
|
||||
end as is_duplicate_booking,
|
||||
*
|
||||
from {{ ref("stg_core__booking") }}
|
||||
from stg_core__booking
|
||||
),
|
||||
-- This next queries are to obtain the original booking_id for those duplicated so
|
||||
-- These next queries are to obtain the original booking_id for those duplicated so
|
||||
-- then we can associate to which booking_id they are duplicated from
|
||||
duplicate_booking as (
|
||||
select
|
||||
|
|
@ -25,7 +26,7 @@ with
|
|||
id_accommodation,
|
||||
check_in_date_utc,
|
||||
count(*) as number_bookings
|
||||
from {{ ref("stg_core__booking") }}
|
||||
from stg_core__booking
|
||||
group by id_user_guest, id_accommodation, check_in_date_utc
|
||||
),
|
||||
stg_core__booking_duplicated as (
|
||||
|
|
@ -38,7 +39,7 @@ with
|
|||
and db.id_accommodation = bdf.id_accommodation
|
||||
and db.check_in_date_utc = bdf.check_in_date_utc
|
||||
)
|
||||
where bdf.is_duplicate_booking is false and db.number_bookings > 1
|
||||
where bdf.is_duplicate_booking = false and db.number_bookings > 1
|
||||
)
|
||||
select
|
||||
db.id_booking,
|
||||
|
|
@ -53,4 +54,4 @@ left join
|
|||
and bd.check_in_date_utc = db.check_in_date_utc
|
||||
and bd.id_booking != db.id_booking
|
||||
)
|
||||
where db.is_duplicate_booking is true
|
||||
where db.is_duplicate_booking = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue