Bird
0
0

You try to use a macro call like {{ analytics.calculate_margin(revenue, cost) }} in your model, but dbt returns an error saying the macro is undefined. What is the most probable reason?

medium📝 Debug Q6 of 15
dbt - Jinja in dbt
You try to use a macro call like {{ analytics.calculate_margin(revenue, cost) }} in your model, but dbt returns an error saying the macro is undefined. What is the most probable reason?
AYou forgot to import the macro inside your model SQL file
BThe macro name 'calculate_margin' is misspelled in your model
CThe 'analytics' project is not listed as a dependency in packages.yml
DMacros cannot be called from other projects in dbt
Step-by-Step Solution
Solution:
  1. Step 1: Check dependencies

    dbt requires external projects to be declared in packages.yml to access their macros.
  2. Step 2: Confirm macro availability

    If the project is not listed, dbt cannot find the macro, causing the error.
  3. Final Answer:

    The 'analytics' project is not listed as a dependency in packages.yml -> Option C
  4. Quick Check:

    Missing dependency causes undefined macro error [OK]
Quick Trick: Always declare external projects in packages.yml [OK]
Common Mistakes:
MISTAKES
  • Assuming macros auto-import without dependencies
  • Thinking macro names are case-insensitive
  • Believing macros must be imported inside SQL files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes