udemy-complete-dbt-bootcamp/code_thingies/dbtlearn/models/mart/mart_fullmoon_reviews.sql

27 lines
488 B
MySQL
Raw Normal View History

2023-10-31 17:22:51 +01:00
{{
config(
materialized = 'table'
)
}}
WITH fact_reviews AS (
SELECT *
FROM
{{ ref('fact_reviews') }}
),
full_moon_dates AS (
SELECT *
FROM
{{ ref('seed_full_moon_dates')}}
)
SELECT
fr.*,
CASE
WHEN fm.full_moon_date IS NULL THEN 'not full moon'
ELSE 'full moon'
END AS is_full_moon
FROM
fact_reviews fr
LEFT JOIN full_moon_dates fm
ON (fr.review_date::date) = (fm.full_moon_date + interval '1' day)