Skip to content

Commit 203d107

Browse files
authored
Merge pull request #5 from calogica/update-dbt-18
Update to dbt 0.18.x
2 parents d83611a + 43aeaad commit 203d107

10 files changed

+41
-33
lines changed

dbt_project.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
name: 'dbt_date'
2-
version: '0.1'
2+
version: '0.2'
3+
4+
config-version: 2
35

46
target-path: "target"
57
clean-targets: ["target", "dbt_modules"]
68
macro-paths: ["macros"]
79
log-path: "logs"
810

9-
require-dbt-version: ">=0.14.0"
10-
profile: dev
11+
require-dbt-version: [">=0.18.0", "<0.19.0"]
12+
profile: integration_tests
13+
1114
quoting:
1215
identifier: false
1316
schema: false
1417

18+
vars:
19+
'dbt_date:time_zone': 'America/Los_Angeles'
20+
1521
models:
16-
vars:
17-
'dbt_date:time_zone': 'America/Los_Angeles'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% macro _get_utils_namespaces() %}
2+
{% set override_namespaces = var('dbt_date_dispatch_list', []) %}
3+
{% do return(override_namespaces + ['dbt_date']) %}
4+
{% endmacro %}
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
{% macro convert_timezone(column, target_tz=None, source_tz=None) %}
1+
{%- macro convert_timezone(column, target_tz=None, source_tz=None) -%}
22
{%- set target_tz = var("dbt_date:time_zone") if not target_tz else target_tz -%}
3-
{{ adapter_macro('dbt_date.convert_timezone', column, target_tz, source_tz) }}
4-
{% endmacro %}
3+
{{ adapter.dispatch('convert_timezone', packages = dbt_date._get_utils_namespaces()) (column, target_tz, source_tz) }}
4+
{%- endmacro -%}
55

6-
{% macro default__convert_timezone(column, target_tz, source_tz) %}
6+
{% macro default__convert_timezone(column, target_tz, source_tz) -%}
77
{%- if not source_tz -%}
88
cast(convert_timezone('{{ target_tz }}', {{ column }}) as {{ dbt_utils.type_timestamp() }})
99
{%- else -%}
1010
cast(convert_timezone('{{ source_tz }}', '{{ target_tz }}', {{ column }}) as {{ dbt_utils.type_timestamp() }})
1111
{%- endif -%}
12-
{% endmacro %}
12+
{%- endmacro -%}
1313

14-
{% macro bigquery__convert_timezone(column, target_tz, source_tz=None) %}
15-
datetime({{ column }}, '{{ target_tz}}')
16-
{% endmacro %}
14+
{%- macro bigquery__convert_timezone(column, target_tz, source_tz=None) -%}
15+
timestamp(datetime({{ column }}, '{{ target_tz}}'))
16+
{%- endmacro -%}

macros/calendar_date/date_part.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% macro date_part(datepart, date) -%}
2-
{{ adapter_macro('dbt_date.date_part', datepart, date) }}
2+
{{ adapter.dispatch('date_part', packages = dbt_date._get_utils_namespaces()) (datepart, date) }}
33
{%- endmacro %}
44

55
{% macro default__date_part(datepart, date) -%}

macros/calendar_date/day_name.sql

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
{% macro day_name(date, short=True) -%}
2-
{{ adapter_macro('dbt_date.day_name', date, short) }}
1+
{%- macro day_name(date, short=True) -%}
2+
{{ adapter.dispatch('day_name', packages = dbt_date._get_utils_namespaces()) (date, short) }}
33
{%- endmacro %}
44

5-
{% macro default__day_name(date, short) -%}
6-
{% set f = 'Dy' if short else 'Day' %}
5+
{%- macro default__day_name(date, short) -%}
6+
{%- set f = 'Dy' if short else 'Day' -%}
77
to_char({{ date }}, '{{ f }}')
88
{%- endmacro %}
99

10-
{% macro bigquery__day_name(date, short) -%}
11-
{% set f = '%a' if short else '%A' %}
10+
{%- macro bigquery__day_name(date, short) -%}
11+
{%- set f = '%a' if short else '%A' -%}
1212
format_date('{{ f }}', cast({{ date }} as date))
1313
{%- endmacro %}

macros/calendar_date/month_name.sql

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
{% macro month_name(date, short=True) -%}
2-
{{ adapter_macro('dbt_date.month_name', date, short) }}
1+
{%- macro month_name(date, short=True) -%}
2+
{{ adapter.dispatch('month_name', packages = dbt_date._get_utils_namespaces()) (date, short) }}
33
{%- endmacro %}
44

5-
{% macro default__month_name(date, short) -%}
6-
{% set f = 'MON' if short else 'MONTH' %}
5+
{%- macro default__month_name(date, short) -%}
6+
{%- set f = 'MON' if short else 'MONTH' -%}
77
to_char({{ date }}, '{{ f }}')
88
{%- endmacro %}
99

10-
{% macro bigquery__month_name(date, short) -%}
11-
{% set f = '%b' if short else '%B' %}
10+
{%- macro bigquery__month_name(date, short) -%}
11+
{%- set f = '%b' if short else '%B' -%}
1212
format_date('{{ f }}', cast({{ date }} as date))
1313
{%- endmacro %}
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
{% macro to_unixtimestamp(timestamp) -%}
2-
{{ adapter_macro('dbt_date.to_unixtimestamp', timestamp) }}
1+
{%- macro to_unixtimestamp(timestamp) -%}
2+
{{ adapter.dispatch('to_unixtimestamp', packages = dbt_date._get_utils_namespaces()) (timestamp) }}
33
{%- endmacro %}
44

5-
{% macro default__to_unixtimestamp(timestamp) -%}
5+
{%- macro default__to_unixtimestamp(timestamp) -%}
66
{{ dbt_date.date_part('epoch_seconds', timestamp) }}
77
{%- endmacro %}
88

9-
{% macro bigquery__to_unixtimestamp(timestamp) -%}
9+
{%- macro bigquery__to_unixtimestamp(timestamp) -%}
1010
unix_seconds({{ timestamp }})
1111
{%- endmacro %}

macros/fiscal_date/get_fiscal_year_dates.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% macro get_fiscal_year_dates(dates, year_end_month=12, week_start_day=1, shift_year=1) %}
2-
{{ adapter_macro('dbt_date.get_fiscal_year_dates', dates, year_end_month, week_start_day, shift_year) }}
2+
{{ adapter.dispatch('get_fiscal_year_dates', packages = dbt_date._get_utils_namespaces()) (dates, year_end_month, week_start_day, shift_year) }}
33
{% endmacro %}
44

55
{% macro default__get_fiscal_year_dates(dates, year_end_month, week_start_day, shift_year) %}

macros/get_date_dimension.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% macro get_date_dimension(start_date, end_date) %}
2-
{{ adapter_macro('dbt_date.get_date_dimension', start_date, end_date) }}
2+
{{ adapter.dispatch('get_date_dimension', packages = dbt_date._get_utils_namespaces()) (start_date, end_date) }}
33
{% endmacro %}
44

55
{% macro default__get_date_dimension(start_date, end_date) %}

packages.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
packages:
22
- package: fishtown-analytics/dbt_utils
3-
version: [">=0.2.0", "<0.3.0"]
3+
version: [">=0.6.0", "<0.7.0"]

0 commit comments

Comments
 (0)