Skip to content

Commit

Permalink
Add fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
NiallRees committed Jan 31, 2025
1 parent 66ab76f commit 2d5ea04
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions models/hourly_spend.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ with hour_spine as (
{% if execute %}
{% set stg_metering_history_relation = load_relation(ref('stg_metering_history')) %}
{% if stg_metering_history_relation %}
{% set results = run_query("select min(convert_timezone('UTC', start_time)) from " ~ ref('stg_metering_history')) %}
{% set results = run_query("select coalesce(min(convert_timezone('UTC', start_time)), '2023-01-01 00:00:00') from " ~ ref('stg_metering_history')) %}
{% set start_date = "'" ~ results.columns[0][0] ~ "'" %}
{% set results = run_query("select dateadd(hour, 1, max(convert_timezone('UTC', start_time))) from " ~ ref('stg_metering_history')) %}
{% set results = run_query("select coalesce(dateadd(hour, 1, max(convert_timezone('UTC', start_time))), '2023-01-01 00:00:00') from " ~ ref('stg_metering_history')) %}
{% set end_date = "'" ~ results.columns[0][0] ~ "'" %}
{% else %}
{% set start_date = "'2023-01-01 00:00:00'" %} {# this is just a dummy date for initial compilations before stg_metering_history exists #}
Expand Down

0 comments on commit 2d5ea04

Please sign in to comment.