More models

This commit is contained in:
Pablo Martin 2023-10-30 18:15:38 +01:00
parent ab581b0fb5
commit 3e8423dbd8
3 changed files with 31 additions and 2 deletions

View file

@ -11,6 +11,8 @@ SELECT
CASE
WHEN flag_is_superhost = 't' THEN true
WHEN flag_is_superhost = 'f' THEN false
END::bool AS flag_is_superhost
END::bool AS flag_is_superhost,
created_at,
updated_at
FROM
src_hosts

View file

@ -0,0 +1,25 @@
WITH
listings AS (
SELECT *
FROM
{{ ref('dim_listings_cleansed') }}
),
hosts AS (
SELECT *
FROM
{{ ref('dim_hosts_cleansed') }}
)
SELECT
listings.listing_id,
listings.listing_name,
listings.room_type,
listings.mininum_nights,
listings.price,
listings.host_id,
hosts.host_name,
hosts.flag_is_superhost,
listings.created_at,
GREATEST(listings.updated_at, hosts.updated_at) AS updated_at
FROM
listings
LEFT JOIN hosts ON (listings.host_id = hosts.host_id)

View file

@ -5,6 +5,8 @@ WITH raw_hosts AS (
SELECT
id as host_id,
name as host_name,
is_superhost as flag_is_superhost
is_superhost as flag_is_superhost,
created_at,
updated_at
FROM
raw_hosts