Last active
June 8, 2020 23:44
-
-
Save robert8138/5c2118a0c98cb2256281aac44ccb2472 to your computer and use it in GitHub Desktop.
Parameterize workflow to incorporate backfill logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%- if backfill %} | |
INSERT OVERWRITE TABLE bookings_summary PARTITION (ds) | |
{%- else %} | |
INSERT OVERWRITE TABLE bookings_summary PARTITION (ds = '{{ ds }}') | |
{%- endif %} | |
SELECT | |
dim_market | |
, SUM(m_bookings) AS m_bookings | |
{%- if backfill %} | |
, ds | |
{%- endif %} | |
FROM | |
fct_bookings | |
WHERE | |
{%- if backfill %} | |
ds BETWEEN '{{ start_date }}' AND '{{ end_date }}' | |
{%- else %} | |
ds = '{{ ds }}' | |
{%- endif %} | |
GROUP BY | |
dim_market | |
{%- if backfill %} | |
, ds | |
{%- endif %} | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment