# cannot render macro, "macro" is undefined

**URL:** <https://discourse.getdbt.com/t/cannot-render-macro-macro-is-undefined/10764>\
**Category:** Help\
**Tags:** custom-schema, dbt-core\
**Created:** [November 14, 2023, 12:40am UTC](https://discourse.getdbt.com/t/cannot-render-macro-macro-is-undefined/10764 "2023-11-14T00:40:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nordrocks](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/nordrocks/32/2366_2.png) [@nordrocks](https://discourse.getdbt.com/u/nordrocks)\
**Post date:** [November 14, 2023, 12:40am UTC](https://discourse.getdbt.com/t/cannot-render-macro-macro-is-undefined/10764/1 "2023-11-14T00:40:18Z")

</div>

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:

```auto
-- macros/test_macro.sql

{% macro test_macro() %}
    {{ return('test_schema') }}
{% endmacro %}

```

```yml
# 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!

---

<div class="post-metadata">

**Author:** ![kanyq](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/kanyq/32/4976_2.png) [@kanyq](https://discourse.getdbt.com/u/kanyq)\
**Post date:** [December 8, 2024, 6:01pm UTC](https://discourse.getdbt.com/t/cannot-render-macro-macro-is-undefined/10764/2 "2024-12-08T18:01:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![spavankumar06](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@spavankumar06](https://discourse.getdbt.com/u/spavankumar06)\
**Post date:** [December 12, 2024, 9:18pm UTC](https://discourse.getdbt.com/t/cannot-render-macro-macro-is-undefined/10764/3 "2024-12-12T21:18:18Z")

</div>

How to fix this issue then, still getting compilation error

---

<div class="post-metadata">

**Author:** ![prathmeshphalke\_bsc](https://avatars.discourse-cdn.com/v4/letter/p/3ab097/32.png) [@prathmeshphalke\_bsc](https://discourse.getdbt.com/u/prathmeshphalke_bsc)\
**Post date:** [December 12, 2024, 9:22pm UTC](https://discourse.getdbt.com/t/cannot-render-macro-macro-is-undefined/10764/4 "2024-12-12T21:22:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [December 15, 2024, 10:45pm UTC](https://discourse.getdbt.com/t/cannot-render-macro-macro-is-undefined/10764/5 "2024-12-15T22:45:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [December 22, 2024, 10:46pm UTC](https://discourse.getdbt.com/t/cannot-render-macro-macro-is-undefined/10764/6 "2024-12-22T22:46:22Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
