-
Notifications
You must be signed in to change notification settings - Fork 10
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 #18 from emilyriederer/whitespace
Fix Jinja templating to improve whitespace in macro results
- Loading branch information
Showing
14 changed files
with
115 additions
and
113 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
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,4 @@ | ||
{% set cols_n = dbtplyr.contains( 'c', ref('data') ) %} | ||
select {{ dbtplyr.across(cols_n, "{{var}}") }} | ||
select | ||
{{ dbtplyr.across(cols_n, "{{var}}") }} | ||
from {{ ref('data') }} |
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,4 @@ | ||
{% set cols_n = dbtplyr.ends_with( 'c', ref('data') ) %} | ||
select {{ dbtplyr.across(cols_n, "{{var}}") }} | ||
select | ||
{{ dbtplyr.across(cols_n, "{{var}}") }} | ||
from {{ ref('data') }} |
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,4 @@ | ||
{% set cols_n = dbtplyr.everything( ref('data')) %} | ||
select {{ dbtplyr.across(cols_n, "{{var}}") }} | ||
select | ||
{{ dbtplyr.across(cols_n, "{{var}}") }} | ||
from {{ ref('data') }} |
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,4 @@ | ||
{% set cols_n = dbtplyr.matches('.*_c', ref('data')) %} | ||
select {{ dbtplyr.across(cols_n, "{{var}}") }} | ||
select | ||
{{ dbtplyr.across(cols_n, "{{var}}") }} | ||
from {{ ref('data') }} |
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,4 @@ | ||
{% set cols_n = dbtplyr.not_contains('n', ref('data')) %} | ||
select {{ dbtplyr.across(cols_n, "{{var}}") }} | ||
select | ||
{{ dbtplyr.across(cols_n, "{{var}}") }} | ||
from {{ ref('data') }} |
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,4 @@ | ||
{% set cols_n = dbtplyr.not_one_of(['n_a', 'ind_a', 'ind_b'], ref('data')) %} | ||
select {{ dbtplyr.across(cols_n, "{{var}}") }} | ||
select | ||
{{ dbtplyr.across(cols_n, "{{var}}") }} | ||
from {{ ref('data') }} |
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,4 @@ | ||
{% set cols_n = dbtplyr.one_of(['amt_c'], ref('data')) %} | ||
select {{ dbtplyr.across(cols_n, "{{var}}") }} | ||
select | ||
{{ dbtplyr.across(cols_n, "{{var}}") }} | ||
from {{ ref('data') }} |
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,4 @@ | ||
{% set cols_n = dbtplyr.starts_with('amt', ref('data')) %} | ||
select {{ dbtplyr.across(cols_n) }} | ||
select | ||
{{ dbtplyr.across(cols_n) }} | ||
from {{ ref('data') }} |
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,28 +1,24 @@ | ||
{% macro across(var_list, script_string = '{{var}}', final_comma = false) %} | ||
{{ adapter.dispatch('across', 'dbtplyr') (var_list, script_string, final_comma) }} | ||
{% endmacro %} | ||
{%- macro across(var_list, script_string = '{{var}}', final_comma = false) -%} | ||
{{- adapter.dispatch('across', 'dbtplyr') (var_list, script_string, final_comma) -}} | ||
{%- endmacro -%} | ||
|
||
{% macro default__across(var_list, script_string, final_comma) %} | ||
{%- macro default__across(var_list, script_string, final_comma) -%} | ||
{%- for v in var_list %} | ||
{{- script_string | replace('{{var}}', v) -}} | ||
{%- if not loop.last -%},{%- endif -%} | ||
{%- if loop.last and final_comma|default(false) -%},{%- endif -%} | ||
{%- endfor -%} | ||
{%- endmacro -%} | ||
|
||
{% for v in var_list %} | ||
{{ script_string | replace('{{var}}', v) }} | ||
{%- if not loop.last %},{% endif %} | ||
{%- if loop.last and final_comma|default(false) %},{% endif %} | ||
{% endfor %} | ||
{%- macro c_across(var_list, script_string) -%} | ||
{{- adapter.dispatch('c_across', 'dbtplyr') (var_list, script_string) -}} | ||
{%- endmacro -%} | ||
|
||
{% endmacro %} | ||
|
||
{% macro c_across(var_list, script_string) %} | ||
{{ adapter.dispatch('c_across', 'dbtplyr') (var_list, script_string) }} | ||
{% endmacro %} | ||
|
||
{% macro default__c_across(var_list, script_string) %} | ||
|
||
{% if script_string | length < 2 %} | ||
{{ var_list | join(script_string) }} | ||
{% else %} | ||
{% set vars = var_list | join(",") %} | ||
{{ script_string | replace('{{var}}', vars) }} | ||
{% endif %} | ||
|
||
{% endmacro %} | ||
{%- macro default__c_across(var_list, script_string) -%} | ||
{%- if script_string | length < 2 -%} | ||
{{- var_list | join(script_string) -}} | ||
{%- else -%} | ||
{%- set vars = var_list | join(",") -%} | ||
{{- script_string | replace('{{var}}', vars) -}} | ||
{%- endif -%} | ||
{%- 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,21 +1,21 @@ | ||
{% macro get_column_names(relation) %} | ||
{%- macro get_column_names(relation) -%} | ||
{{ return( adapter.dispatch('get_column_names', 'dbtplyr')(relation) ) }} | ||
{% endmacro %} | ||
{%- endmacro -%} | ||
|
||
{% macro default__get_column_names(relation) %} | ||
{%- macro default__get_column_names(relation) -%} | ||
|
||
{# if relation is not actually a reference simply pass through #} | ||
{# this is useful so downstream functions can accept either list or relation #} | ||
|
||
{% if relation.database is not defined %} | ||
{%- if relation.database is not defined -%} | ||
{{ return(relation) }} | ||
{% endif %} | ||
{%- endif -%} | ||
|
||
{%- set cols_list = adapter.get_columns_in_relation(relation) -%} | ||
{% set results_list = [] %} | ||
{% for c in cols_list %} | ||
{{ results_list.append(c.name) }} | ||
{% endfor %} | ||
{%- set results_list = [] -%} | ||
{%- for c in cols_list -%} | ||
{{ results_list.append(c.name) }} | ||
{%- endfor -%} | ||
{{ return(results_list) }} | ||
|
||
{% endmacro %} | ||
{%- 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