diff --git a/macros/get_directory_pattern.sql b/macros/get_directory_pattern.sql index 8ad21ec8..e16caefb 100644 --- a/macros/get_directory_pattern.sql +++ b/macros/get_directory_pattern.sql @@ -1,11 +1,19 @@ -- 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 is_os_mac_or_linux() %} + {% for val in graph.nodes.values() %} + {{ return("\\" not in val.get("original_file_path","")) }} + {% endfor %} + {{ return(true) }} +{% endmacro %} + {% 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("\\\\") }} + {% if execute %} + {%- set on_mac_or_linux = dbt_project_evaluator.is_os_mac_or_linux() -%} + {%- if on_mac_or_linux -%} + {{ return("/") }} + {% else %} + {{ return("\\\\") }} + {% endif %} {% endif %} {% endmacro %} @@ -15,11 +23,12 @@ {% 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,'.*\\\\\\\\','')", "''") }} + {% if execute %} + {%- set on_mac_or_linux = dbt_project_evaluator.is_os_mac_or_linux() -%} + {%- if on_mac_or_linux -%} + {{ dbt.replace("file_path", "regexp_replace(file_path,'.*/','')", "''") }} + {% else %} + {{ dbt.replace("file_path", "regexp_replace(file_path,'.*\\\\\\\\','')", "''") }} + {% endif %} {% endif %} {% endmacro %} \ No newline at end of file