Compile error - two sources with same name

Hi, all!

I’m using environment variables inside my source_defs.yml for the first time since our source schemas have different names in dev/QA vs. production. Everything was running fine until the beginning of this week when I started getting the following error while trying to compile:

Compilation Error dbt found two sources with the name “[model_name]_[table_name]”.

Since these resources have the same name, dbt will be unable to find the correct resource when looking for source(“[model_name]”, “[table_name]”).

To fix this, change the name of one of these resources:

  • source.edw.[model_name].[table_name] (models/source_defs.yml)
  • source.edw.[model_name].[table_name] (models/source_defs.yml)

Both resource names that it wants me to change are identical.

I’ve checked dbt_projects.yml to make sure that the model doesn’t exist multiple times, run a search in source_defs.yml to make sure that the table isn’t referenced multiple times, and checked the folder structure to make sure I only have one script with that name. I’ve validated that the values of the environment variables are unique within each environment.

If I remove the first table in that source from source_defs, I get the same error using the new first table in that source.

The models run fine from the jobs, but I’m unable to compile/preview to test new changes to my models.

Does anyone have any suggestions of what I can check next to try to clear the error? Or what might be causing it?

Thanks in advance!

I would try running a dbt clean to remove the target artifacts (or deleting them manually) and then run it again