@@ -324,3 +324,46 @@ def test_macro_depenency_none_str():
324324
325325 # "None" macro shouldn't raise a KeyError
326326 _macro_references (helper ._manifest , node )
327+
328+
329+ @pytest .mark .xdist_group ("dbt_manifest" )
330+ def test_macro_assignment_shadowing (create_empty_project ):
331+ project_name = "local"
332+ project_path , models_path = create_empty_project (project_name = project_name )
333+
334+ macros_path = project_path / "macros"
335+ macros_path .mkdir ()
336+
337+ (macros_path / "model_path_macro.sql" ).write_text ("""
338+ {% macro model_path_macro() %}
339+ {% if execute %}
340+ {% set model = model.path.split('/')[-1].replace('.sql', '') %}
341+ SELECT '{{ model }}' as model_name
342+ {% else %}
343+ SELECT 'placeholder' as placeholder
344+ {% endif %}
345+ {% endmacro %}
346+ """ )
347+
348+ (models_path / "model_using_path_macro.sql" ).write_text ("""
349+ {{ model_path_macro() }}
350+ """ )
351+
352+ context = DbtContext (project_path )
353+ profile = Profile .load (context )
354+
355+ helper = ManifestHelper (
356+ project_path ,
357+ project_path ,
358+ project_name ,
359+ profile .target ,
360+ model_defaults = ModelDefaultsConfig (start = "2020-01-01" ),
361+ )
362+
363+ macros = helper .macros (project_name )
364+ assert "model_path_macro" in macros
365+ assert "path" in macros ["model_path_macro" ].dependencies .model_attrs .attrs
366+
367+ models = helper .models ()
368+ assert "model_using_path_macro" in models
369+ assert "path" in models ["model_using_path_macro" ].dependencies .model_attrs .attrs
0 commit comments