-
Notifications
You must be signed in to change notification settings - Fork 70
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 #237 from dbt-labs/bug/directory_pattern
Bug/directory pattern
- Loading branch information
Showing
4 changed files
with
39 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- these macros will read a user’s home environment and detect whether a computer’s operating system is Windows based or Mac/Linux, and display the right directory pattern. | ||
{% macro get_directory_pattern() %} | ||
{%- set env_var_home_exists = env_var("HOME", "not_set") != "not_set" -%} | ||
{%- set on_mac_or_linux = env_var_home_exists and "\\\\" not in env_var("HOME") -%} | ||
{%- if on_mac_or_linux -%} | ||
{{ return("/") }} | ||
{% else %} | ||
{{ return("\\\\") }} | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
{% macro get_regexp_directory_pattern() %} | ||
{% set regexp_escaped = get_directory_pattern() | replace("\\\\", "\\\\\\\\") %} | ||
{% do return(regexp_escaped) %} | ||
{% endmacro %} | ||
|
||
{% macro get_dbtreplace_directory_pattern() %} | ||
{%- set env_var_home_exists = env_var("HOME", "not_set") != "not_set" -%} | ||
{%- set on_mac_or_linux = env_var_home_exists and "\\\\" not in env_var("HOME") -%} | ||
{%- if on_mac_or_linux -%} | ||
{{ dbt.replace("file_path", "regexp_replace(file_path,'.*/','')", "''") }} | ||
{% else %} | ||
{{ dbt.replace("file_path", "regexp_replace(file_path,'.*\\\\\\\\','')", "''") }} | ||
{% 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
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