[Bug] Macro override in unit test doesn't work when used in a local variable
Is this a new bug in dbt-core?
- [x] I believe this is a new bug in dbt-core
- [x] I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
Unit test setup:
- name: unit_test_A
model: some_model
overrides:
macros:
dbt_utils.star: col_a,col_b
The mock values for some_model are also set.
Variable in dbt model:
{% set some_list = dbt_utils.star(from=some_model) %}
{{ print(some_list) }}
{{ print(dbt_utils.star(from=some_model)) }}
When running the unit test the first print statement will print a list of empty strings: ['', '']. The second print statement will print the override.
Expected Behavior
If the results of a macro are used to set a variable the override of the macro should be returned in the macro call.
Steps To Reproduce
- Create a dbt model that sets a variable with the result of
dbt_utils.star - Set a print statement to print the variable value
- Create a unit test that overrides the macro and mocks the values of
some_model - Run the unit test to see the list of empty strings printed
Relevant log output
Environment
- OS: macOS 26.1
- Python: 3.10.18
- dbt: 1.9.4
Which database adapter are you using with dbt?
snowflake
Additional Context
No response
Hey @colombian-cannonball - thanks for opening this issue!
I've attempted to reproduce it locally through a test: https://github.com/dbt-labs/dbt-core/pull/12214. However, I have not been able to reproduce the inconsistency between accessing an overriden macro output whether its a from a variable that was set vs calling the macro directly.
I've also run this test on the latest 1.9 version as well as the reported 1.9.4 version and observed the same expected behavior.
Could you please take a look at the test defined above and let me know if I'm missing something in capturing the reproduction case?