cannot render macro, "macro" is undefined

Creating a test macro throws the error in the project.yml file when debugging: Compilation Error
Could not render {{ test_macro() }}: ‘test_macro’ is undefined

dbt version: 1.7.0

Nothing seems to be wrong with the dbt syntax
macro:

-- macros/test_macro.sql

{% macro test_macro() %}
    {{ return('test_schema') }}
{% endmacro %}
# dbt_project.yml

    +generate_schema_name: "{{ test_macro() }}"

I’m sure there would be a simple explanation for this, but very glad if someone could point me in the right direction. Thanks!

Hi, The dbt_project.yml file is processed before the macros are compiled, meaning that any macro calls made in this file will not be recognized, leading to the compilation error.

How to fix this issue then, still getting compilation error

I am in similar boat as well. any help is appreciated.

please open a new post describing what you’re trying to achieve, including the code you’re trying to run