-
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
check for node name uniqueness across refable resource types #737
Conversation
dbt/compilation.py
Outdated
dbt.exceptions.raise_duplicate_resource_name(resource, | ||
existing_name) | ||
|
||
names_resources[name] = resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have logic like this anywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code previously existed in the loader, but I ripped it out and put it in the compiler class. I liked the idea of the Loader just returning a flat graph and not validating uniqueness or other business logic constraints. It feels like that will be important if we expose the loader through our API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do something similar here: https://github.com/fishtown-analytics/dbt/blob/development/dbt/parser.py#L290
dbt/exceptions.py
Outdated
def raise_duplicate_resource_name(resource_1_name, resource_2_name): | ||
raise_compiler_error( | ||
'Found two resources with the same name: \n- {}\n- {}'.format( | ||
resource_1_name, resource_2_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cmcarthur I accidentally deleted your comment 🙃
You asked if these resources were full paths or just node names.
I think the answer is that it's both, depending where we call this. Will update the code to make it consistent
@cmcarthur I cleaned up the code and improved the error message. Now the exception function just takes a couple of nodes. Seems like a better approach. New error:
We do need to check this twice, since the flat map is a dict of We need to check a second time to assert uniqueness across projects and resources types. |
* check for node name uniqueness across refable resource types * change test for new error msg * consistent error message for dupes * small refactor, improve error msg * fix tests automatic commit by git-black, original commits: e20796e
fixes: #736
This came up because a view model and a seed file had the same name. Previously, dbt's check for name uniqueness only pertained to models.