-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Unit test raising error '<macro name>' is undefined. This can happen when calling a macro that does not exist.
#10157
Comments
Worth confirming would this happen by itself without unittest |
This works fine for me if I do not have any dbt unit tests defined: dbt build -s +model_f But if I add a dbt unit test and re-run that same command, then it gives the error. |
I can confirm that I'm experiencing this as well. ContextI'm using dbt-core 1.8.3 with dbt-snowflake 1.8.3 on macOS Ventura 13.6. I'm developing a custom dbt package which defines a suite of macros. I'm experiencing the error in my package's When running either Please let us know when you've root-caused this bug, since it will be a huge roadblock for me and my team to pivot to using native DBT unit tests as opposed to the EqualExperts unit testing framework (which doesn't seem to suffer from this bug). Thanks in advance! |
Thanks for sharing some of the specifics of your scenario @dsillman2000 👍 If a constant return value is sufficient for the purposes of your unit test, a workaround is to use an macros:
# explicity set star to relevant list of columns
dbt_utils.star: col_a,col_b,col_c Otherwise, there isn't a known workaround. You can stay subscribed to this issue in GitHub to get notified of updates regarding further root cause or resolution. |
I am having the same issue, {% macro test_macro() %} in dbt_project.yml I have set up the path correctly and call the macros: macro-paths: ["macros"] But when I run dbt debug I got this error: Could not render {{ test_macro() }}: 'test_macro' is undefined Have anyone firgured out with happened? |
I'm running into this issue again, in a new project, with a macro defined within the project (more similar to the minimum reproducible example above). Unfortunately, even setting an I don't know if this should be filed as a separate bug with the "Overrides" section of the subject unit test case:
After running
Running the same model with As with my testimony above, I'm using dbt-core 1.8.3 and dbt-snowflake 1.8.3 macOS Ventura 13.6. |
Moments after posting above, I had a breakthrough @dbeatty10 ! Please try it in your minimum reproducible example project to see if it works / helps you root cause the issue. Work-around:
Note that this also allows the This suggests to me that the broken link must be in how dbt is resolving macros differently in a set block context as opposed to other contexts. Please let me know if you're able to reproduce this work-around in your example case above! |
Is this a new bug in dbt-core?
Current Behavior
Sometimes (but not always!), I get this compilation error when a model contains a macro:
Expected Behavior
This seems like it should work without needing to add an override for any macros.
Steps To Reproduce
macros/my_macros.sql
models/_unit_tests.yml
models/model_f.sql
Build and see that everything works just fine:
Update
models/model_f.sql
to add{% set ab_values = a_values + b_values %}
anywhere within the model defintion:Now re-build and see the error:
Relevant log output
Environment
Which database adapter are you using with dbt?
postgres
Additional Context
Found while researching #10139.
The text was updated successfully, but these errors were encountered: