Skip to content

Commit

Permalink
Improve test fixture for date_spine macro to work with multiple ada…
Browse files Browse the repository at this point in the history
…pters
  • Loading branch information
QMalcolm committed Sep 14, 2023
1 parent be7ffb3 commit 7fa5715
Showing 1 changed file with 67 additions and 18 deletions.
85 changes: 67 additions & 18 deletions tests/adapter/dbt/tests/adapter/utils/fixture_date_spine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,74 @@

models__test_date_spine_sql = """
with generated_dates as (
{{ date_spine("day", "'2023-09-01'::date", "'2023-09-10'::date") }}
{% if target.type == 'postgres' %}
{{ date_spine("day", "'2023-09-01'::date", "'2023-09-10'::date") }}
{% elif target.type == 'bigquery' %}
select cast(date_day as date) as date_day
from ({{ date_spine("day", "'2023-09-01'", "'2023-09-10'") }})
{% else %}
{{ date_spine("day", "'2023-09-01'", "'2023-09-10'") }}
{% endif %}
), expected_dates as (
select '2023-09-01'::date as expected
union all
select '2023-09-02'::date as expected
union all
select '2023-09-03'::date as expected
union all
select '2023-09-04'::date as expected
union all
select '2023-09-05'::date as expected
union all
select '2023-09-06'::date as expected
union all
select '2023-09-07'::date as expected
union all
select '2023-09-08'::date as expected
union all
select '2023-09-09'::date as expected
{% if target.type == 'postgres' %}
select '2023-09-01'::date as expected
union all
select '2023-09-02'::date as expected
union all
select '2023-09-03'::date as expected
union all
select '2023-09-04'::date as expected
union all
select '2023-09-05'::date as expected
union all
select '2023-09-06'::date as expected
union all
select '2023-09-07'::date as expected
union all
select '2023-09-08'::date as expected
union all
select '2023-09-09'::date as expected
{% elif target.type == 'bigquery' %}
select cast('2023-09-01' as date) as expected
union all
select cast('2023-09-02' as date) as expected
union all
select cast('2023-09-03' as date) as expected
union all
select cast('2023-09-04' as date) as expected
union all
select cast('2023-09-05' as date) as expected
union all
select cast('2023-09-06' as date) as expected
union all
select cast('2023-09-07' as date) as expected
union all
select cast('2023-09-08' as date) as expected
union all
select cast('2023-09-09' as date) as expected
{% else %}
select '2023-09-01' as expected
union all
select '2023-09-02' as expected
union all
select '2023-09-03' as expected
union all
select '2023-09-04' as expected
union all
select '2023-09-05' as expected
union all
select '2023-09-06' as expected
union all
select '2023-09-07' as expected
union all
select '2023-09-08' as expected
union all
select '2023-09-09' as expected
{% endif %}
), joined as (
select
generated_dates.date_day,
Expand Down

0 comments on commit 7fa5715

Please sign in to comment.