fixed model name and dump tables
This commit is contained in:
parent
cbd1b4414f
commit
2a897c6ead
2 changed files with 51 additions and 62 deletions
|
|
@ -1,62 +0,0 @@
|
||||||
with
|
|
||||||
stg_core__accommodation_to_user as (
|
|
||||||
select * from {{ ref("stg_core__accommodation_to_user")}}
|
|
||||||
),
|
|
||||||
stg_core__accommodation as (
|
|
||||||
select * from {{ ref("stg_core__accommodation")}}
|
|
||||||
),
|
|
||||||
stg_core__user as (
|
|
||||||
select * from {{ ref("stg_core__user")}}
|
|
||||||
),
|
|
||||||
stg_core__verification_set as (
|
|
||||||
select
|
|
||||||
id_user_host,
|
|
||||||
id_verification_set
|
|
||||||
from {{ ref("stg_core__verification_set")}}
|
|
||||||
),
|
|
||||||
stg_core__verification_set_to_verification_type as (
|
|
||||||
select
|
|
||||||
id_verification_set,
|
|
||||||
id_verification_type
|
|
||||||
from {{ ref("stg_core__verification_set_to_verification_type")}}
|
|
||||||
)
|
|
||||||
select
|
|
||||||
atu.id_user_owner as id_user_host,
|
|
||||||
atu.id_accommodation,
|
|
||||||
atu.accommodation_user_type,
|
|
||||||
atu.created_at_utc,
|
|
||||||
atu.updated_at_utc,
|
|
||||||
ac.friendly_name,
|
|
||||||
ac.id_country,
|
|
||||||
ac.is_active,
|
|
||||||
ac.town,
|
|
||||||
ac.address_line_1,
|
|
||||||
us.email,
|
|
||||||
us.joined_at_utc,
|
|
||||||
us.joined_date_utc,
|
|
||||||
us.last_name,
|
|
||||||
us.user_name,
|
|
||||||
us.first_name,
|
|
||||||
us.company_name,
|
|
||||||
us.phone_number
|
|
||||||
from
|
|
||||||
stg_core__accommodation_to_user atu
|
|
||||||
left join
|
|
||||||
stg_core__accommodation ac on atu.id_accommodation = ac.id_accommodation
|
|
||||||
left join
|
|
||||||
stg_core__user us on atu.id_user_owner = us.id_user
|
|
||||||
inner join (
|
|
||||||
select
|
|
||||||
vs.id_user_host,
|
|
||||||
vs.id_verification_set,
|
|
||||||
vstvt.id_verification_set,
|
|
||||||
vstvt.id_verification_type
|
|
||||||
FROM
|
|
||||||
stg_core__verification_set vs
|
|
||||||
left join
|
|
||||||
stg_core__verification_set_to_verification_type vstvt on vs.id_verification_set = vstvt.id_verification_set
|
|
||||||
where
|
|
||||||
vs.is_active is true and
|
|
||||||
vstvt.id_verification_type = 15
|
|
||||||
) as vsat on vsat.id_user_host = atu.id_user_owner
|
|
||||||
order by atu.id_user_owner, atu.id_accommodation
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
with
|
||||||
|
stg_core__accommodation_to_user as (
|
||||||
|
select * from {{ ref("stg_core__accommodation_to_user") }}
|
||||||
|
),
|
||||||
|
stg_core__accommodation as (select * from {{ ref("stg_core__accommodation") }}),
|
||||||
|
stg_core__user as (select * from {{ ref("stg_core__user") }}),
|
||||||
|
stg_core__verification_set as (
|
||||||
|
select id_user_host, id_verification_set, is_active
|
||||||
|
from {{ ref("stg_core__verification_set") }}
|
||||||
|
),
|
||||||
|
stg_core__verification_set_to_verification_type as (
|
||||||
|
select id_verification_set, id_verification_type
|
||||||
|
from {{ ref("stg_core__verification_set_to_verification_type") }}
|
||||||
|
)
|
||||||
|
select
|
||||||
|
atu.id_user_owner as id_user_host,
|
||||||
|
atu.id_accommodation,
|
||||||
|
atu.accommodation_user_type,
|
||||||
|
atu.created_at_utc,
|
||||||
|
atu.updated_at_utc,
|
||||||
|
ac.friendly_name,
|
||||||
|
ac.id_country,
|
||||||
|
ac.is_active,
|
||||||
|
ac.town,
|
||||||
|
ac.address_line_1,
|
||||||
|
us.email,
|
||||||
|
us.joined_at_utc,
|
||||||
|
us.joined_date_utc,
|
||||||
|
us.last_name,
|
||||||
|
us.user_name,
|
||||||
|
us.first_name,
|
||||||
|
us.company_name,
|
||||||
|
us.phone_number
|
||||||
|
from stg_core__accommodation_to_user atu
|
||||||
|
left join stg_core__accommodation ac on atu.id_accommodation = ac.id_accommodation
|
||||||
|
left join stg_core__user us on atu.id_user_owner = us.id_user
|
||||||
|
inner join
|
||||||
|
(
|
||||||
|
select
|
||||||
|
vs.id_user_host,
|
||||||
|
vs.id_verification_set,
|
||||||
|
vstvt.id_verification_set,
|
||||||
|
vstvt.id_verification_type
|
||||||
|
from stg_core__verification_set vs
|
||||||
|
left join
|
||||||
|
stg_core__verification_set_to_verification_type vstvt
|
||||||
|
on vs.id_verification_set = vstvt.id_verification_set
|
||||||
|
where vs.is_active is true and vstvt.id_verification_type = 15
|
||||||
|
) as vsat
|
||||||
|
on vsat.id_user_host = atu.id_user_owner
|
||||||
|
order by atu.id_user_owner, atu.id_accommodation
|
||||||
Loading…
Add table
Add a link
Reference in a new issue