Skip to content

Commit cd776bf

Browse files
sdebruynclaude
andcommitted
Handle backslash path separators in Fabric file_path extraction
The Fabric-specific charindex/left/right logic only handled forward slashes. Windows users running dbt against Fabric would get incorrect directory_path and file_name values. Now dispatches on is_os_mac_or_linux like the non-Fabric branches already do. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 57ffc9e commit cd776bf

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

macros/get_directory_pattern.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
{% macro get_dbtreplace_directory_pattern() %}
2626
{% if execute %}
2727
{%- if target.type == 'fabric' -%}
28-
left(file_path, len(file_path) - charindex('/', reverse(file_path)))
28+
{%- set on_mac_or_linux = dbt_project_evaluator.is_os_mac_or_linux() -%}
29+
{%- if on_mac_or_linux -%}
30+
left(file_path, len(file_path) - charindex('/', reverse(file_path)))
31+
{%- else -%}
32+
left(file_path, len(file_path) - charindex('\', reverse(file_path)))
33+
{%- endif -%}
2934
{%- else -%}
3035
{%- set on_mac_or_linux = dbt_project_evaluator.is_os_mac_or_linux() -%}
3136
{%- if on_mac_or_linux -%}

models/marts/core/int_all_graph_resources.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ unioned_with_calc as (
5151
end as prefix,
5252
{{ get_dbtreplace_directory_pattern() }} as directory_path,
5353
{% if target.type == 'fabric' %}
54+
{%- set on_mac_or_linux = dbt_project_evaluator.is_os_mac_or_linux() -%}
55+
{%- if on_mac_or_linux -%}
5456
right(file_path, charindex('/', reverse(file_path)) - 1) as file_name
57+
{%- else -%}
58+
right(file_path, charindex('\', reverse(file_path)) - 1) as file_name
59+
{%- endif -%}
5560
{% else %}
5661
regexp_replace(file_path,'.*{{ get_regexp_directory_pattern() }}','') as file_name
5762
{% endif %}

0 commit comments

Comments
 (0)