From e4d1d9362fcec08a81ed12120f026de4ee423ea3 Mon Sep 17 00:00:00 2001 From: Claus Herther Date: Wed, 28 Dec 2022 10:34:42 -0800 Subject: [PATCH] Update refs to dbt-core macros --- integration_tests/macros/get_test_dates.sql | 16 ++++----- macros/_utils/date_spine.sql | 6 ++-- macros/calendar_date/convert_timezone.sql | 6 ++-- macros/calendar_date/day_of_month.sql | 2 +- macros/calendar_date/day_of_week.sql | 8 ++--- macros/calendar_date/day_of_year.sql | 2 +- macros/calendar_date/iso_week_of_year.sql | 2 +- macros/calendar_date/iso_week_start.sql | 2 +- macros/calendar_date/n_days_ago.sql | 2 +- macros/calendar_date/n_months_ago.sql | 4 +-- macros/calendar_date/n_months_away.sql | 4 +-- macros/calendar_date/n_weeks_ago.sql | 4 +-- macros/calendar_date/n_weeks_away.sql | 4 +-- macros/calendar_date/periods_since.sql | 2 +- macros/calendar_date/round_timestamp.sql | 2 +- macros/calendar_date/week_of_year.sql | 4 +-- macros/calendar_date/week_start.sql | 6 ++-- macros/fiscal_date/get_fiscal_periods.sql | 6 ++-- macros/fiscal_date/get_fiscal_year_dates.sql | 6 ++-- macros/get_base_dates.sql | 12 +++---- macros/get_date_dimension.sql | 38 ++++++++++---------- 21 files changed, 69 insertions(+), 69 deletions(-) diff --git a/integration_tests/macros/get_test_dates.sql b/integration_tests/macros/get_test_dates.sql index 428e303..6d264ec 100644 --- a/integration_tests/macros/get_test_dates.sql +++ b/integration_tests/macros/get_test_dates.sql @@ -20,10 +20,10 @@ select 'November' as month_name, 'Nov' as month_name_short, 1623076520 as unix_epoch, - cast('{{ get_test_timestamps()[0] }}' as {{ type_timestamp() }}) as time_stamp, - cast('{{ get_test_timestamps()[1] }}' as {{ type_timestamp() }}) as time_stamp_utc, - cast('2021-06-07' as {{ type_timestamp() }}) as rounded_timestamp, - cast('2021-06-08' as {{ type_timestamp() }}) as rounded_timestamp_utc, + cast('{{ get_test_timestamps()[0] }}' as {{ dbt.type_timestamp() }}) as time_stamp, + cast('{{ get_test_timestamps()[1] }}' as {{ dbt.type_timestamp() }}) as time_stamp_utc, + cast('2021-06-07' as {{ dbt.type_timestamp() }}) as rounded_timestamp, + cast('2021-06-08' as {{ dbt.type_timestamp() }}) as rounded_timestamp_utc, -- These columns are here to make sure these macros get run during testing: {{ dbt_date.last_month_number() }} as last_month_number, {{ dbt_date.last_month_name(short=False) }} as last_month_name, @@ -54,10 +54,10 @@ select 'December' as month_name, 'Dec' as month_name_short, 1623076520 as unix_epoch, - cast('{{ get_test_timestamps()[0] }}' as {{ type_timestamp() }}) as time_stamp, - cast('{{ get_test_timestamps()[1] }}' as {{ type_timestamp() }}) as time_stamp_utc, - cast('2021-06-07' as {{ type_timestamp() }}) as rounded_timestamp, - cast('2021-06-08' as {{ type_timestamp() }}) as rounded_timestamp_utc, + cast('{{ get_test_timestamps()[0] }}' as {{ dbt.type_timestamp() }}) as time_stamp, + cast('{{ get_test_timestamps()[1] }}' as {{ dbt.type_timestamp() }}) as time_stamp_utc, + cast('2021-06-07' as {{ dbt.type_timestamp() }}) as rounded_timestamp, + cast('2021-06-08' as {{ dbt.type_timestamp() }}) as rounded_timestamp_utc, -- These columns are here to make sure these macros get run during testing: {{ dbt_date.last_month_number() }} as last_month_number, {{ dbt_date.last_month_name(short=False) }} as last_month_name, diff --git a/macros/_utils/date_spine.sql b/macros/_utils/date_spine.sql index 639132c..d936c57 100644 --- a/macros/_utils/date_spine.sql +++ b/macros/_utils/date_spine.sql @@ -5,7 +5,7 @@ {% macro default__get_intervals_between(start_date, end_date, datepart) -%} {%- call statement('get_intervals_between', fetch_result=True) %} - select {{ datediff(start_date, end_date, datepart) }} + select {{ dbt.datediff(start_date, end_date, datepart) }} {%- endcall -%} @@ -35,7 +35,7 @@ date_spine( "day", "to_date('01/01/2016', 'mm/dd/yyyy')", - "dateadd(week, 1, current_date)" + "dbt.dateadd(week, 1, current_date)" ) #} @@ -53,7 +53,7 @@ all_periods as ( select ( {{ - dateadd( + dbt.dateadd( datepart, "row_number() over (order by 1) - 1", start_date diff --git a/macros/calendar_date/convert_timezone.sql b/macros/calendar_date/convert_timezone.sql index e1aac68..529d49a 100644 --- a/macros/calendar_date/convert_timezone.sql +++ b/macros/calendar_date/convert_timezone.sql @@ -6,7 +6,7 @@ {% macro default__convert_timezone(column, target_tz, source_tz) -%} convert_timezone('{{ source_tz }}', '{{ target_tz }}', - cast({{ column }} as {{ type_timestamp() }}) + cast({{ column }} as {{ dbt.type_timestamp() }}) ) {%- endmacro -%} @@ -23,8 +23,8 @@ from_utc_timestamp( {% macro postgres__convert_timezone(column, target_tz, source_tz) -%} cast( - cast({{ column }} as {{ type_timestamp() }}) - at time zone '{{ source_tz }}' at time zone '{{ target_tz }}' as {{ type_timestamp() }} + cast({{ column }} as {{ dbt.type_timestamp() }}) + at time zone '{{ source_tz }}' at time zone '{{ target_tz }}' as {{ dbt.type_timestamp() }} ) {%- endmacro -%} diff --git a/macros/calendar_date/day_of_month.sql b/macros/calendar_date/day_of_month.sql index fef7868..4b2c6e3 100644 --- a/macros/calendar_date/day_of_month.sql +++ b/macros/calendar_date/day_of_month.sql @@ -3,5 +3,5 @@ {%- endmacro %} {%- macro redshift__day_of_month(date) -%} -cast({{ dbt_date.date_part('day', date) }} as {{ type_bigint() }}) +cast({{ dbt_date.date_part('day', date) }} as {{ dbt.type_bigint() }}) {%- endmacro %} diff --git a/macros/calendar_date/day_of_week.sql b/macros/calendar_date/day_of_week.sql index 3281323..ce918bc 100644 --- a/macros/calendar_date/day_of_week.sql +++ b/macros/calendar_date/day_of_week.sql @@ -57,11 +57,11 @@ {%- if isoweek -%} {%- set dow_part = 'isodow' -%} -- Monday(1) to Sunday (7) - cast({{ dbt_date.date_part(dow_part, date) }} as {{ type_int() }}) + cast({{ dbt_date.date_part(dow_part, date) }} as {{ dbt.type_int() }}) {%- else -%} {%- set dow_part = 'dow' -%} -- Sunday(1) to Saturday (7) - cast({{ dbt_date.date_part(dow_part, date) }} + 1 as {{ type_int() }}) + cast({{ dbt_date.date_part(dow_part, date) }} + 1 as {{ dbt.type_int() }}) {%- endif -%} {%- endmacro %} @@ -75,10 +75,10 @@ case -- Shift start of week from Sunday (0) to Monday (1) when {{ dow }} = 0 then 7 - else cast({{ dow }} as {{ type_bigint() }}) + else cast({{ dow }} as {{ dbt.type_bigint() }}) end {%- else -%} - cast({{ dow }} + 1 as {{ type_bigint() }}) + cast({{ dow }} + 1 as {{ dbt.type_bigint() }}) {%- endif -%} {%- endmacro %} diff --git a/macros/calendar_date/day_of_year.sql b/macros/calendar_date/day_of_year.sql index 8c89c72..1c2a931 100644 --- a/macros/calendar_date/day_of_year.sql +++ b/macros/calendar_date/day_of_year.sql @@ -11,5 +11,5 @@ {%- endmacro %} {%- macro redshift__day_of_year(date) -%} - cast({{ dbt_date.date_part('dayofyear', date) }} as {{ type_bigint() }}) + cast({{ dbt_date.date_part('dayofyear', date) }} as {{ dbt.type_bigint() }}) {%- endmacro %} diff --git a/macros/calendar_date/iso_week_of_year.sql b/macros/calendar_date/iso_week_of_year.sql index 09d9093..f3f5f3c 100644 --- a/macros/calendar_date/iso_week_of_year.sql +++ b/macros/calendar_date/iso_week_of_year.sql @@ -4,7 +4,7 @@ {%- endmacro -%} {%- macro _iso_week_of_year(date, week_type) -%} -cast({{ dbt_date.date_part(week_type, date) }} as {{ type_int() }}) +cast({{ dbt_date.date_part(week_type, date) }} as {{ dbt.type_int() }}) {%- endmacro %} {%- macro default__iso_week_of_year(date) -%} diff --git a/macros/calendar_date/iso_week_start.sql b/macros/calendar_date/iso_week_start.sql index c0b63b3..d3c2ad7 100644 --- a/macros/calendar_date/iso_week_start.sql +++ b/macros/calendar_date/iso_week_start.sql @@ -4,7 +4,7 @@ {%- endmacro -%} {%- macro _iso_week_start(date, week_type) -%} -cast({{ date_trunc(week_type, date) }} as date) +cast({{ dbt.date_trunc(week_type, date) }} as date) {%- endmacro %} {%- macro default__iso_week_start(date) -%} diff --git a/macros/calendar_date/n_days_ago.sql b/macros/calendar_date/n_days_ago.sql index ccf289e..2735f24 100644 --- a/macros/calendar_date/n_days_ago.sql +++ b/macros/calendar_date/n_days_ago.sql @@ -1,5 +1,5 @@ {%- macro n_days_ago(n, date=None, tz=None) -%} {%-set dt = date if date else dbt_date.today(tz) -%} {%- set n = n|int -%} -cast({{ dateadd('day', -1 * n, dt) }} as date) +cast({{ dbt.dateadd('day', -1 * n, dt) }} as date) {%- endmacro -%} diff --git a/macros/calendar_date/n_months_ago.sql b/macros/calendar_date/n_months_ago.sql index 019bbbc..d5b1b20 100644 --- a/macros/calendar_date/n_months_ago.sql +++ b/macros/calendar_date/n_months_ago.sql @@ -1,7 +1,7 @@ {%- macro n_months_ago(n, tz=None) -%} {%- set n = n|int -%} -{{ date_trunc('month', - dateadd('month', -1 * n, +{{ dbt.date_trunc('month', + dbt.dateadd('month', -1 * n, dbt_date.today(tz) ) ) }} diff --git a/macros/calendar_date/n_months_away.sql b/macros/calendar_date/n_months_away.sql index 9064f4e..f93fbaa 100644 --- a/macros/calendar_date/n_months_away.sql +++ b/macros/calendar_date/n_months_away.sql @@ -1,7 +1,7 @@ {%- macro n_months_away(n, tz=None) -%} {%- set n = n|int -%} -{{ date_trunc('month', - dateadd('month', n, +{{ dbt.date_trunc('month', + dbt.dateadd('month', n, dbt_date.today(tz) ) ) }} diff --git a/macros/calendar_date/n_weeks_ago.sql b/macros/calendar_date/n_weeks_ago.sql index 6ed036d..61f35f2 100644 --- a/macros/calendar_date/n_weeks_ago.sql +++ b/macros/calendar_date/n_weeks_ago.sql @@ -1,7 +1,7 @@ {%- macro n_weeks_ago(n, tz=None) -%} {%- set n = n|int -%} -{{ date_trunc('week', - dateadd('week', -1 * n, +{{ dbt.date_trunc('week', + dbt.dateadd('week', -1 * n, dbt_date.today(tz) ) ) }} diff --git a/macros/calendar_date/n_weeks_away.sql b/macros/calendar_date/n_weeks_away.sql index 6ce7a7f..21652e4 100644 --- a/macros/calendar_date/n_weeks_away.sql +++ b/macros/calendar_date/n_weeks_away.sql @@ -1,7 +1,7 @@ {%- macro n_weeks_away(n, tz=None) -%} {%- set n = n|int -%} -{{ date_trunc('week', - dateadd('week', n, +{{ dbt.date_trunc('week', + dbt.dateadd('week', n, dbt_date.today(tz) ) ) }} diff --git a/macros/calendar_date/periods_since.sql b/macros/calendar_date/periods_since.sql index 85c16d5..c3c2b3a 100644 --- a/macros/calendar_date/periods_since.sql +++ b/macros/calendar_date/periods_since.sql @@ -1,3 +1,3 @@ {%- macro periods_since(date_col, period_name='day', tz=None) -%} -{{ datediff(date_col, dbt_date.now(tz), period_name) }} +{{ dbt.datediff(date_col, dbt_date.now(tz), period_name) }} {%- endmacro -%} diff --git a/macros/calendar_date/round_timestamp.sql b/macros/calendar_date/round_timestamp.sql index 034368c..7fd17fd 100644 --- a/macros/calendar_date/round_timestamp.sql +++ b/macros/calendar_date/round_timestamp.sql @@ -1,3 +1,3 @@ {% macro round_timestamp(timestamp) %} - {{ date_trunc("day", dateadd("hour", 12, timestamp)) }} + {{ dbt.date_trunc("day", dbt.dateadd("hour", 12, timestamp)) }} {% endmacro %} diff --git a/macros/calendar_date/week_of_year.sql b/macros/calendar_date/week_of_year.sql index ff4457d..63904be 100644 --- a/macros/calendar_date/week_of_year.sql +++ b/macros/calendar_date/week_of_year.sql @@ -4,11 +4,11 @@ {%- endmacro -%} {%- macro default__week_of_year(date) -%} -cast({{ dbt_date.date_part('week', date) }} as {{ type_int() }}) +cast({{ dbt_date.date_part('week', date) }} as {{ dbt.type_int() }}) {%- endmacro %} {%- macro postgres__week_of_year(date) -%} {# postgresql 'week' returns isoweek. Use to_char instead. WW = the first week starts on the first day of the year #} -cast(to_char({{ date }}, 'WW') as {{ type_int() }}) +cast(to_char({{ date }}, 'WW') as {{ dbt.type_int() }}) {%- endmacro %} diff --git a/macros/calendar_date/week_start.sql b/macros/calendar_date/week_start.sql index 85e5e94..5c79d3e 100644 --- a/macros/calendar_date/week_start.sql +++ b/macros/calendar_date/week_start.sql @@ -4,7 +4,7 @@ {%- endmacro -%} {%- macro default__week_start(date) -%} -cast({{ date_trunc('week', date) }} as date) +cast({{ dbt.date_trunc('week', date) }} as date) {%- endmacro %} {%- macro snowflake__week_start(date) -%} @@ -13,10 +13,10 @@ cast({{ date_trunc('week', date) }} as date) dbt_date.day_of_week returns 1, so we subtract 1 to get a 0 offset #} {% set off_set = dbt_date.day_of_week(date, isoweek=False) ~ " - 1" %} - cast({{ dateadd("day", "-1 * (" ~ off_set ~ ")", date) }} as date) + cast({{ dbt.dateadd("day", "-1 * (" ~ off_set ~ ")", date) }} as date) {%- endmacro %} {%- macro postgres__week_start(date) -%} -- Sunday as week start date -cast({{ dateadd('day', -1, date_trunc('week', dateadd('day', 1, date))) }} as date) +cast({{ dbt.dateadd('day', -1, dbt.date_trunc('week', dbt.dateadd('day', 1, date))) }} as date) {%- endmacro %} diff --git a/macros/fiscal_date/get_fiscal_periods.sql b/macros/fiscal_date/get_fiscal_periods.sql index b8d317a..bb8c5c1 100644 --- a/macros/fiscal_date/get_fiscal_periods.sql +++ b/macros/fiscal_date/get_fiscal_periods.sql @@ -13,14 +13,14 @@ fscl_year_w13 as ( -- We count the weeks in a 13 week period -- and separate the 4-5-4 week sequences mod(cast( - (f.fiscal_week_of_year-1) as {{ type_int() }} + (f.fiscal_week_of_year-1) as {{ dbt.type_int() }} ), 13) as w13_number, -- Chop weeks into 13 week merch quarters cast( least( floor((f.fiscal_week_of_year-1)/13.0) , 3) - as {{ type_int() }}) as quarter_number + as {{ dbt.type_int() }}) as quarter_number from fscl_year_dates_for_periods f @@ -51,7 +51,7 @@ fscl_periods_quarters as ( f.*, cast(( (f.quarter_number * 3) + f.period_of_quarter - ) as {{ type_int() }}) as fiscal_period_number + ) as {{ dbt.type_int() }}) as fiscal_period_number from fscl_periods f diff --git a/macros/fiscal_date/get_fiscal_year_dates.sql b/macros/fiscal_date/get_fiscal_year_dates.sql index 65b45c6..990a3d9 100644 --- a/macros/fiscal_date/get_fiscal_year_dates.sql +++ b/macros/fiscal_date/get_fiscal_year_dates.sql @@ -27,7 +27,7 @@ weeks as ( d.year_number, d.month_of_year, d.date_day as week_start_date, - cast({{ dateadd('day', 6, 'd.date_day') }} as date) as week_end_date + cast({{ dbt.dateadd('day', 6, 'd.date_day') }} as date) as week_end_date from date_dimension d where @@ -58,7 +58,7 @@ weeks_at_month_end as ( rank() over (partition by d.fiscal_year_number order by - abs({{ datediff('d.week_end_date', 'm.month_end_date', 'day') }}) + abs({{ dbt.datediff('d.week_end_date', 'm.month_end_date', 'day') }}) ) as closest_to_month_end from @@ -71,7 +71,7 @@ fiscal_year_range as ( select w.fiscal_year_number, cast( - {{ dateadd('day', 1, + {{ dbt.dateadd('day', 1, 'lag(w.week_end_date) over(order by w.week_end_date)') }} as date) as fiscal_year_start_date, w.week_end_date as fiscal_year_end_date diff --git a/macros/get_base_dates.sql b/macros/get_base_dates.sql index f72a763..5f5b878 100644 --- a/macros/get_base_dates.sql +++ b/macros/get_base_dates.sql @@ -5,12 +5,12 @@ {% macro default__get_base_dates(start_date, end_date, n_dateparts, datepart) %} {%- if start_date and end_date -%} -{%- set start_date="cast('" ~ start_date ~ "' as " ~ type_timestamp() ~ ")" -%} -{%- set end_date="cast('" ~ end_date ~ "' as " ~ type_timestamp() ~ ")" -%} +{%- set start_date="cast('" ~ start_date ~ "' as " ~ dbt.type_timestamp() ~ ")" -%} +{%- set end_date="cast('" ~ end_date ~ "' as " ~ dbt.type_timestamp() ~ ")" -%} {%- elif n_dateparts and datepart -%} -{%- set start_date = dateadd(datepart, -1 * n_dateparts, dbt_date.today()) -%} +{%- set start_date = dbt.dateadd(datepart, -1 * n_dateparts, dbt_date.today()) -%} {%- set end_date = dbt_date.tomorrow() -%} {%- endif -%} @@ -26,7 +26,7 @@ with date_spine as ) select - cast(d.date_{{ datepart }} as {{ type_timestamp() }}) as date_{{ datepart }} + cast(d.date_{{ datepart }} as {{ dbt.type_timestamp() }}) as date_{{ datepart }} from date_spine d {% endmacro %} @@ -39,7 +39,7 @@ from {%- elif n_dateparts and datepart -%} -{%- set start_date = dateadd(datepart, -1 * n_dateparts, dbt_date.today()) -%} +{%- set start_date = dbt.dateadd(datepart, -1 * n_dateparts, dbt_date.today()) -%} {%- set end_date = dbt_date.tomorrow() -%} {%- endif -%} @@ -55,7 +55,7 @@ with date_spine as ) select - cast(d.date_{{ datepart }} as {{ type_timestamp() }}) as date_{{ datepart }} + cast(d.date_{{ datepart }} as {{ dbt.type_timestamp() }}) as date_{{ datepart }} from date_spine d {% endmacro %} diff --git a/macros/get_date_dimension.sql b/macros/get_date_dimension.sql index 70e5e7a..7a5efc7 100644 --- a/macros/get_date_dimension.sql +++ b/macros/get_date_dimension.sql @@ -10,8 +10,8 @@ dates_with_prior_year_dates as ( select cast(d.date_day as date) as date_day, - cast({{ dateadd('year', -1 , 'd.date_day') }} as date) as prior_year_date_day, - cast({{ dateadd('day', -364 , 'd.date_day') }} as date) as prior_year_over_year_date_day + cast({{ dbt.dateadd('year', -1 , 'd.date_day') }} as date) as prior_year_date_day, + cast({{ dbt.dateadd('day', -364 , 'd.date_day') }} as date) as prior_year_over_year_date_day from base_dates d @@ -44,22 +44,22 @@ select {{ dbt_date.week_of_year('d.prior_year_over_year_date_day') }} as prior_year_week_of_year, {{ dbt_date.iso_week_of_year('d.prior_year_over_year_date_day') }} as prior_year_iso_week_of_year, - cast({{ dbt_date.date_part('month', 'd.date_day') }} as {{ type_int() }}) as month_of_year, + cast({{ dbt_date.date_part('month', 'd.date_day') }} as {{ dbt.type_int() }}) as month_of_year, {{ dbt_date.month_name('d.date_day', short=false) }} as month_name, {{ dbt_date.month_name('d.date_day', short=true) }} as month_name_short, - cast({{ date_trunc('month', 'd.date_day') }} as date) as month_start_date, + cast({{ dbt.date_trunc('month', 'd.date_day') }} as date) as month_start_date, cast({{ last_day('d.date_day', 'month') }} as date) as month_end_date, - cast({{ date_trunc('month', 'd.prior_year_date_day') }} as date) as prior_year_month_start_date, + cast({{ dbt.date_trunc('month', 'd.prior_year_date_day') }} as date) as prior_year_month_start_date, cast({{ last_day('d.prior_year_date_day', 'month') }} as date) as prior_year_month_end_date, - cast({{ dbt_date.date_part('quarter', 'd.date_day') }} as {{ type_int() }}) as quarter_of_year, - cast({{ date_trunc('quarter', 'd.date_day') }} as date) as quarter_start_date, + cast({{ dbt_date.date_part('quarter', 'd.date_day') }} as {{ dbt.type_int() }}) as quarter_of_year, + cast({{ dbt.date_trunc('quarter', 'd.date_day') }} as date) as quarter_start_date, cast({{ last_day('d.date_day', 'quarter') }} as date) as quarter_end_date, - cast({{ dbt_date.date_part('year', 'd.date_day') }} as {{ type_int() }}) as year_number, - cast({{ date_trunc('year', 'd.date_day') }} as date) as year_start_date, + cast({{ dbt_date.date_part('year', 'd.date_day') }} as {{ dbt.type_int() }}) as year_number, + cast({{ dbt.date_trunc('year', 'd.date_day') }} as date) as year_start_date, cast({{ last_day('d.date_day', 'year') }} as date) as year_end_date from dates_with_prior_year_dates d @@ -74,8 +74,8 @@ dates_with_prior_year_dates as ( select cast(d.date_day as date) as date_day, - cast({{ dateadd('year', -1 , 'd.date_day') }} as date) as prior_year_date_day, - cast({{ dateadd('day', -364 , 'd.date_day') }} as date) as prior_year_over_year_date_day + cast({{ dbt.dateadd('year', -1 , 'd.date_day') }} as date) as prior_year_date_day, + cast({{ dbt.dateadd('day', -364 , 'd.date_day') }} as date) as prior_year_over_year_date_day from base_dates d @@ -108,23 +108,23 @@ select {{ dbt_date.week_of_year('d.prior_year_over_year_date_day') }} as prior_year_week_of_year, {{ dbt_date.iso_week_of_year('d.prior_year_over_year_date_day') }} as prior_year_iso_week_of_year, - cast({{ dbt_date.date_part('month', 'd.date_day') }} as {{ type_int() }}) as month_of_year, + cast({{ dbt_date.date_part('month', 'd.date_day') }} as {{ dbt.type_int() }}) as month_of_year, {{ dbt_date.month_name('d.date_day', short=false) }} as month_name, {{ dbt_date.month_name('d.date_day', short=true) }} as month_name_short, - cast({{ date_trunc('month', 'd.date_day') }} as date) as month_start_date, + cast({{ dbt.date_trunc('month', 'd.date_day') }} as date) as month_start_date, cast({{ last_day('d.date_day', 'month') }} as date) as month_end_date, - cast({{ date_trunc('month', 'd.prior_year_date_day') }} as date) as prior_year_month_start_date, + cast({{ dbt.date_trunc('month', 'd.prior_year_date_day') }} as date) as prior_year_month_start_date, cast({{ last_day('d.prior_year_date_day', 'month') }} as date) as prior_year_month_end_date, - cast({{ dbt_date.date_part('quarter', 'd.date_day') }} as {{ type_int() }}) as quarter_of_year, - cast({{ date_trunc('quarter', 'd.date_day') }} as date) as quarter_start_date, + cast({{ dbt_date.date_part('quarter', 'd.date_day') }} as {{ dbt.type_int() }}) as quarter_of_year, + cast({{ dbt.date_trunc('quarter', 'd.date_day') }} as date) as quarter_start_date, {# last_day does not support quarter because postgresql does not support quarter interval. #} - cast({{dateadd('day', '-1', dateadd('month', '3', date_trunc('quarter', 'd.date_day')))}} as date) as quarter_end_date, + cast({{dbt.dateadd('day', '-1', dbt.dateadd('month', '3', dbt.date_trunc('quarter', 'd.date_day')))}} as date) as quarter_end_date, - cast({{ dbt_date.date_part('year', 'd.date_day') }} as {{ type_int() }}) as year_number, - cast({{ date_trunc('year', 'd.date_day') }} as date) as year_start_date, + cast({{ dbt_date.date_part('year', 'd.date_day') }} as {{ dbt.type_int() }}) as year_number, + cast({{ dbt.date_trunc('year', 'd.date_day') }} as date) as year_start_date, cast({{ last_day('d.date_day', 'year') }} as date) as year_end_date from dates_with_prior_year_dates d