Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid false positives in date_spine macro #211

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 4 additions & 40 deletions dbt-tests-adapter/dbt/tests/adapter/utils/fixture_date_spine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,31 @@
models__test_date_spine_sql = """
with generated_dates as (
{% if target.type == 'postgres' %}
{{ date_spine("day", "'2023-09-01'::date", "'2023-09-10'::date") }}
{{ date_spine("day", "'2023-09-07'::date", "'2023-09-10'::date") }}

{% elif target.type == 'bigquery' or target.type == 'redshift' %}
select cast(date_day as date) as date_day
from ({{ date_spine("day", "'2023-09-01'", "'2023-09-10'") }})
from ({{ date_spine("day", "'2023-09-07'", "'2023-09-10'") }})

{% else %}
{{ date_spine("day", "'2023-09-01'", "'2023-09-10'") }}
{{ date_spine("day", "'2023-09-07'", "'2023-09-10'") }}
{% endif %}
), expected_dates as (
{% 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' or target.type == 'redshift' %}
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
Expand All @@ -75,7 +39,7 @@
generated_dates.date_day,
expected_dates.expected
from generated_dates
left join expected_dates on generated_dates.date_day = expected_dates.expected
full outer join expected_dates on generated_dates.date_day = expected_dates.expected
)

SELECT * from joined
Expand Down
Loading