Open gwenwindflower opened 3 months ago
Thanks for raising this @gwenwindflower !
We could definitely take a look at rephrasing this error message so that it is easier to understand and take action upon. The relevant code is here and here.
We've been reserving the bug
label for when dbt is behaving in an obviously incorrect way and then using enhancement
when dbt has room to improve somehow (like a more helpful error message). So I'm going to re-label this as a help wanted
enhancement / feature request.
What do you think about one of these variants as the new error message?
When the macro definitions are in different files:
dbt found multiple macros named "cents_to_dollars" in the project "jaffle shop".
To fix this error, rename or remove duplicates. They can be found in these files:
- macros/hi_doug.sql
- macros/hi_jer.sql
When the macro definitions are in the same file:
dbt found multiple macros named "cents_to_dollars" in the project "jaffle shop".
To fix this error, rename or remove duplicates. They can be found in this file:
- macros/cents_to_dollars.sql
Note: It looks to me like dbt will immediately stop and raise an error message upon the first duplicate (rather than collecting all of them first). That's why I replaced "[n] macros" with "multiple macros" for practical purposes.
thank you @dbeatty10 yea i couldn't decided between bug and enhancement — good to know for the future! i can take a crack at this i love a great error message!
Is this a new bug in dbt-core?
Current Behavior
Reported from a user in Community Slack.
These two listed files contain duplicate macros, but confuse users because we list the file names, not the macros. Not only that, but in my repro I discovered that we always say "two" instead of how many duplicates actually exist and only report the first two files that conflict. That last bit may not be fixable given that we error out when it happens, but I propose that ideally we should say something like:
My repro error from straight Core:
User from Slack's error (looks like dbt Power User):
Expected Behavior
I would expect dbt to give me a clearer error re which files contain all the duplicate macros
Steps To Reproduce
dbt compile
Relevant log output
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
No response