-
Notifications
You must be signed in to change notification settings - Fork 28
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 #249 from ScalefreeCOM/add-macros-for-global-begin…
…ning-and-end-of-all-times-dates Add macros for global beginning and end of all times dates
- Loading branch information
Showing
5 changed files
with
491 additions
and
22 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
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,155 @@ | ||
{%- macro beginning_of_all_times_date() %} | ||
|
||
{{ return( adapter.dispatch('beginning_of_all_times_date', 'datavault4dbt')() ) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro default__beginning_of_all_times_date() %} | ||
|
||
{%- set global_var = var('datavault4dbt.beginning_of_all_times_date', none) -%} | ||
{%- set beginning_of_all_times_date = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'bigquery' in global_var.keys()|map('lower') -%} | ||
{% set beginning_of_all_times_date = global_var['bigquery'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.beginning_of_all_times_date' to a dictionary, but have not included the adapter you use (bigquery) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set beginning_of_all_times_date = global_var -%} | ||
{%- else -%} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{%- endif -%} | ||
|
||
{{ return(beginning_of_all_times_date) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro snowflake__beginning_of_all_times_date() %} | ||
|
||
{%- set global_var = var('datavault4dbt.beginning_of_all_times_date', none) -%} | ||
{%- set beginning_of_all_times_date = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'snowflake' in global_var.keys()|map('lower') -%} | ||
{% set beginning_of_all_times_date = global_var['snowflake'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.beginning_of_all_times_date' to a dictionary, but have not included the adapter you use (snowflake) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set beginning_of_all_times_date = global_var -%} | ||
{%- else -%} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{%- endif -%} | ||
|
||
{{ return(beginning_of_all_times_date) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro exasol__beginning_of_all_times_date() %} | ||
|
||
{%- set global_var = var('datavault4dbt.beginning_of_all_times_date', none) -%} | ||
{%- set beginning_of_all_times_date = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'exasol' in global_var.keys()|map('lower') -%} | ||
{% set beginning_of_all_times_date = global_var['exasol'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.beginning_of_all_times_date' to a dictionary, but have not included the adapter you use (exasol) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set beginning_of_all_times_date = global_var -%} | ||
{%- else -%} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{%- endif -%} | ||
|
||
{{ return(beginning_of_all_times_date) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro synapse__beginning_of_all_times_date() %} | ||
|
||
{%- set global_var = var('datavault4dbt.beginning_of_all_times_date', none) -%} | ||
{%- set beginning_of_all_times_date = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'synapse' in global_var.keys()|map('lower') -%} | ||
{% set beginning_of_all_times_date = global_var['synapse'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.beginning_of_all_times_date' to a dictionary, but have not included the adapter you use (synapse) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set beginning_of_all_times_date = "1901-01-01" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set beginning_of_all_times_date = global_var -%} | ||
{%- else -%} | ||
{%- set beginning_of_all_times_date = "1901-01-01" -%} | ||
{%- endif -%} | ||
|
||
{{ return(beginning_of_all_times_date) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro postgres__beginning_of_all_times_date() %} | ||
|
||
{%- set global_var = var('datavault4dbt.beginning_of_all_times_date', none) -%} | ||
{%- set beginning_of_all_times_date = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'postgres' in global_var.keys()|map('lower') -%} | ||
{% set beginning_of_all_times_date = global_var['postgres'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.beginning_of_all_times_date' to a dictionary, but have not included the adapter you use (postgres) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set beginning_of_all_times_date = global_var -%} | ||
{%- else -%} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{%- endif -%} | ||
|
||
{{ return(beginning_of_all_times_date) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro redshift__beginning_of_all_times_date() %} | ||
|
||
{%- set global_var = var('datavault4dbt.beginning_of_all_times_date', none) -%} | ||
{%- set beginning_of_all_times_date = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'redshift' in global_var.keys()|map('lower') -%} | ||
{% set beginning_of_all_times_date = global_var['redshift'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.beginning_of_all_times_date' to a dictionary, but have not included the adapter you use (redshift) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set beginning_of_all_times_date = global_var -%} | ||
{%- else -%} | ||
{%- set beginning_of_all_times_date = "0001-01-01" -%} | ||
{%- endif -%} | ||
|
||
{{ return(beginning_of_all_times_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 |
---|---|---|
@@ -0,0 +1,154 @@ | ||
{%- macro date_format() %} | ||
|
||
{{ return(adapter.dispatch('date_format', 'datavault4dbt')()) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro default__date_format() %} | ||
|
||
{%- set global_var = var('datavault4dbt.date_format', none) -%} | ||
{%- set date_format = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'bigquery' in global_var.keys()|map('lower') -%} | ||
{% set date_format = global_var['bigquery'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.date_format' to a dictionary, but have not included the adapter you use (bigquery) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set date_format = "%Y-%m-%d" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set date_format = global_var -%} | ||
{%- else -%} | ||
{%- set date_format = "%Y-%m-%d" -%} | ||
{%- endif -%} | ||
|
||
{{ return(date_format) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro snowflake__date_format() %} | ||
|
||
{%- set global_var = var('datavault4dbt.date_format', none) -%} | ||
{%- set date_format = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'snowflake' in global_var.keys()|map('lower') -%} | ||
{% set date_format = global_var['snowflake'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.date_format' to a dictionary, but have not included the adapter you use (snowflake) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set date_format = "YYYY-MM-DD" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set date_format = global_var -%} | ||
{%- else -%} | ||
{%- set date_format = "YYYY-MM-DD" -%} | ||
{%- endif -%} | ||
|
||
{{ return(date_format) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro exasol__date_format() %} | ||
|
||
{%- set global_var = var('datavault4dbt.date_format', none) -%} | ||
{%- set date_format = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'exasol' in global_var.keys()|map('lower') -%} | ||
{% set date_format = global_var['exasol'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.date_format' to a dictionary, but have not included the adapter you use (exasol) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set date_format = "YYYY-mm-dd" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set date_format = global_var -%} | ||
{%- else -%} | ||
{%- set date_format = "YYYY-mm-dd" -%} | ||
{%- endif -%} | ||
|
||
{{ return(date_format) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro synapse__date_format() %} | ||
|
||
{%- set global_var = var('datavault4dbt.date_format', none) -%} | ||
{%- set date_format = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'synapse' in global_var.keys()|map('lower') -%} | ||
{% set date_format = global_var['synapse'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.date_format' to a dictionary, but have not included the adapter you use (synapse) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set date_format = "yyyy-MM-dd" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set date_format = global_var -%} | ||
{%- else -%} | ||
{%- set date_format = "yyyy-MM-dd" -%} | ||
{%- endif -%} | ||
|
||
{{ return(date_format) }} | ||
|
||
{%- endmacro -%} | ||
|
||
|
||
{%- macro postgres__date_format() %} | ||
|
||
{%- set global_var = var('datavault4dbt.date_format', none) -%} | ||
{%- set date_format = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'postgres' in global_var.keys()|map('lower') -%} | ||
{% set date_format = global_var['postgres'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.date_format' to a dictionary, but have not included the adapter you use (postgres) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set date_format = "YYYY-MM-DD" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set date_format = global_var -%} | ||
{%- else -%} | ||
{%- set date_format = "YYYY-MM-DD" -%} | ||
{%- endif -%} | ||
|
||
{{ return(date_format) }} | ||
|
||
{%- endmacro -%} | ||
|
||
{%- macro redshift__date_format() %} | ||
|
||
{%- set global_var = var('datavault4dbt.date_format', none) -%} | ||
{%- set date_format = '' -%} | ||
|
||
{%- if global_var is mapping -%} | ||
{%- if 'redshift' in global_var.keys()|map('lower') -%} | ||
{% set date_format = global_var['redshift'] %} | ||
{%- else -%} | ||
{%- if execute -%} | ||
{%- do exceptions.warn("Warning: You have set the global variable 'datavault4dbt.date_format' to a dictionary, but have not included the adapter you use (redshift) as a key. Applying the default value.") -%} | ||
{% endif %} | ||
{%- set date_format = "YYYY-MM-DD" -%} | ||
{% endif %} | ||
{%- elif global_var is not mapping and datavault4dbt.is_something(global_var) -%} | ||
{%- set date_format = global_var -%} | ||
{%- else -%} | ||
{%- set date_format = "YYYY-MM-DD" -%} | ||
{%- endif -%} | ||
|
||
{{ return(date_format) }} | ||
|
||
{%- endmacro -%} |
Oops, something went wrong.