Skip to content
New issue

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

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

Already on GitHub? # to your account

simplify shimming #27

Merged
merged 3 commits into from
May 30, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ clean-targets:
require-dbt-version: ">=0.18.1"

vars:
dbt_date_dispatch_list: ['dbt_date_integration_tests']
"dbt_date:time_zone": "America/Los_Angeles"

quoting:
Expand Down
4 changes: 0 additions & 4 deletions integration_tests/macros/_get_utils_namespaces.sql

This file was deleted.

64 changes: 15 additions & 49 deletions integration_tests/macros/get_test_dates.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{% macro get_test_dates() -%}
{{ return(adapter.dispatch('get_test_dates', packages = dbt_date_integration_tests._get_utils_namespaces()) ()) }}
{%- endmacro %}

{% macro default__get_test_dates() -%}
select
cast('2020-11-29' as date) as date_day,
cast('2020-11-28' as date) as prior_date_day,
Expand All @@ -15,7 +11,7 @@ select
334 as day_of_year,
cast('2020-11-29' as date) as week_start_date,
cast('2020-12-05' as date) as week_end_date,
48 as week_of_year,
{{ get_test_week_of_year()[0] }} as week_of_year,
-- in ISO terms, this is the end of the prior week
cast('2020-11-23' as date) as iso_week_start_date,
cast('2020-11-29' as date) as iso_week_end_date,
Expand All @@ -37,56 +33,26 @@ select
336 as day_of_year,
cast('2020-11-29' as date) as week_start_date,
cast('2020-12-05' as date) as week_end_date,
48 as week_of_year,

{{ get_test_week_of_year()[1] }} as week_of_year,
cast('2020-11-30' as date) as iso_week_start_date,
cast('2020-12-06' as date) as iso_week_end_date,
49 as iso_week_of_year,
'December' as month_name,
'Dec' as month_name_short
{%- endmacro %}

{% macro snowflake__get_test_dates() -%}
select
cast('2020-11-29' as date) as date_day,
cast('2020-11-28' as date) as prior_date_day,
cast('2020-11-30' as date) as next_date_day,
'Sunday' as day_name,
'Sun' as day_name_short,
29 as day_of_month,
1 as day_of_week,
7 as iso_day_of_week,
334 as day_of_year,
cast('2020-11-29' as date) as week_start_date,
cast('2020-12-05' as date) as week_end_date,
48 as week_of_year,
-- in ISO terms, this is the end of the prior week
cast('2020-11-23' as date) as iso_week_start_date,
cast('2020-11-29' as date) as iso_week_end_date,
48 as iso_week_of_year,
'November' as month_name,
'Nov' as month_name_short

union all

select
cast('2020-12-01' as date) as date_day,
cast('2020-11-30' as date) as prior_date_day,
cast('2020-12-02' as date) as next_date_day,
'Tuesday' as day_name,
'Tue' as day_name_short,
1 as day_of_month,
3 as day_of_week,
2 as iso_day_of_week,
336 as day_of_year,
cast('2020-11-29' as date) as week_start_date,
cast('2020-12-05' as date) as week_end_date,
-- Snowflake returns ISO week numbers with the standard config
49 as week_of_year,
{% macro get_test_week_of_year() -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works for now, although this seems a bit harder to follow for anyone new than simply having a separate test dataset for each platform.

{{ return(adapter.dispatch('get_test_week_of_year', packages = dbt_date._get_utils_namespaces()) ()) }}
{%- endmacro %}

cast('2020-11-30' as date) as iso_week_start_date,
cast('2020-12-06' as date) as iso_week_end_date,
49 as iso_week_of_year,
'December' as month_name,
'Dec' as month_name_short
{% macro default__get_test_week_of_year() -%}
{{ log("in default macro", info=True) }}
{# weeks_of_year for '2020-11-29' and '2020-12-01', respectively #}
{{ return([48,48]) }}
{%- endmacro %}

{% macro snowflake__get_test_week_of_year() -%}
{# weeks_of_year for '2020-11-29' and '2020-12-01', respectively #}
{# Snowflake uses ISO year #}
{{ return([48,49]) }}
{%- endmacro %}