-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from calogica/update-dbt-18
Update to dbt 0.18.x
- Loading branch information
Showing
10 changed files
with
41 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
name: 'dbt_date' | ||
version: '0.1' | ||
version: '0.2' | ||
|
||
config-version: 2 | ||
|
||
target-path: "target" | ||
clean-targets: ["target", "dbt_modules"] | ||
macro-paths: ["macros"] | ||
log-path: "logs" | ||
|
||
require-dbt-version: ">=0.14.0" | ||
profile: dev | ||
require-dbt-version: [">=0.18.0", "<0.19.0"] | ||
profile: integration_tests | ||
|
||
quoting: | ||
identifier: false | ||
schema: false | ||
|
||
vars: | ||
'dbt_date:time_zone': 'America/Los_Angeles' | ||
|
||
models: | ||
vars: | ||
'dbt_date:time_zone': 'America/Los_Angeles' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% macro _get_utils_namespaces() %} | ||
{% set override_namespaces = var('dbt_date_dispatch_list', []) %} | ||
{% do return(override_namespaces + ['dbt_date']) %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{% macro convert_timezone(column, target_tz=None, source_tz=None) %} | ||
{%- macro convert_timezone(column, target_tz=None, source_tz=None) -%} | ||
{%- set target_tz = var("dbt_date:time_zone") if not target_tz else target_tz -%} | ||
{{ adapter_macro('dbt_date.convert_timezone', column, target_tz, source_tz) }} | ||
{% endmacro %} | ||
{{ adapter.dispatch('convert_timezone', packages = dbt_date._get_utils_namespaces()) (column, target_tz, source_tz) }} | ||
{%- endmacro -%} | ||
|
||
{% macro default__convert_timezone(column, target_tz, source_tz) %} | ||
{% macro default__convert_timezone(column, target_tz, source_tz) -%} | ||
{%- if not source_tz -%} | ||
cast(convert_timezone('{{ target_tz }}', {{ column }}) as {{ dbt_utils.type_timestamp() }}) | ||
{%- else -%} | ||
cast(convert_timezone('{{ source_tz }}', '{{ target_tz }}', {{ column }}) as {{ dbt_utils.type_timestamp() }}) | ||
{%- endif -%} | ||
{% endmacro %} | ||
{%- endmacro -%} | ||
|
||
{% macro bigquery__convert_timezone(column, target_tz, source_tz=None) %} | ||
datetime({{ column }}, '{{ target_tz}}') | ||
{% endmacro %} | ||
{%- macro bigquery__convert_timezone(column, target_tz, source_tz=None) -%} | ||
timestamp(datetime({{ column }}, '{{ target_tz}}')) | ||
{%- endmacro -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{% macro day_name(date, short=True) -%} | ||
{{ adapter_macro('dbt_date.day_name', date, short) }} | ||
{%- macro day_name(date, short=True) -%} | ||
{{ adapter.dispatch('day_name', packages = dbt_date._get_utils_namespaces()) (date, short) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__day_name(date, short) -%} | ||
{% set f = 'Dy' if short else 'Day' %} | ||
{%- macro default__day_name(date, short) -%} | ||
{%- set f = 'Dy' if short else 'Day' -%} | ||
to_char({{ date }}, '{{ f }}') | ||
{%- endmacro %} | ||
|
||
{% macro bigquery__day_name(date, short) -%} | ||
{% set f = '%a' if short else '%A' %} | ||
{%- macro bigquery__day_name(date, short) -%} | ||
{%- set f = '%a' if short else '%A' -%} | ||
format_date('{{ f }}', cast({{ date }} as date)) | ||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{% macro month_name(date, short=True) -%} | ||
{{ adapter_macro('dbt_date.month_name', date, short) }} | ||
{%- macro month_name(date, short=True) -%} | ||
{{ adapter.dispatch('month_name', packages = dbt_date._get_utils_namespaces()) (date, short) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__month_name(date, short) -%} | ||
{% set f = 'MON' if short else 'MONTH' %} | ||
{%- macro default__month_name(date, short) -%} | ||
{%- set f = 'MON' if short else 'MONTH' -%} | ||
to_char({{ date }}, '{{ f }}') | ||
{%- endmacro %} | ||
|
||
{% macro bigquery__month_name(date, short) -%} | ||
{% set f = '%b' if short else '%B' %} | ||
{%- macro bigquery__month_name(date, short) -%} | ||
{%- set f = '%b' if short else '%B' -%} | ||
format_date('{{ f }}', cast({{ date }} as date)) | ||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{% macro to_unixtimestamp(timestamp) -%} | ||
{{ adapter_macro('dbt_date.to_unixtimestamp', timestamp) }} | ||
{%- macro to_unixtimestamp(timestamp) -%} | ||
{{ adapter.dispatch('to_unixtimestamp', packages = dbt_date._get_utils_namespaces()) (timestamp) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__to_unixtimestamp(timestamp) -%} | ||
{%- macro default__to_unixtimestamp(timestamp) -%} | ||
{{ dbt_date.date_part('epoch_seconds', timestamp) }} | ||
{%- endmacro %} | ||
|
||
{% macro bigquery__to_unixtimestamp(timestamp) -%} | ||
{%- macro bigquery__to_unixtimestamp(timestamp) -%} | ||
unix_seconds({{ timestamp }}) | ||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
packages: | ||
- package: fishtown-analytics/dbt_utils | ||
version: [">=0.2.0", "<0.3.0"] | ||
version: [">=0.6.0", "<0.7.0"] |