dbt-labs / dbt-core

dbt enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.
https://getdbt.com
Apache License 2.0
9.66k stars 1.6k forks source link

[CT-2077] [Bug] duplicate model conflict with sub projects #6932

Closed leo-schick closed 1 year ago

leo-schick commented 1 year ago

Is this a new bug in dbt-core?

Current Behavior

I have two projects:

When I parse the project, I get the error that the model TaxTrans exist twice.

Only option I can work around myself is renaming TaxTrans in the databricks_dwh project to something else and use a alias. But this is not something I want to do. Sub projects should not mess up my main project model naming(!) And to adjust the sub project doesn't make much sence to me. Then I mess up the model naming there. I want to have consistent, clear naming in the projects themselve.

Expected Behavior

I would expect that the parsing works out and that dbt by default let the TaxTrans model in the databricks_dwh win. It should only redirect to the TaxTrans of the source_ax12 project when I reference to it explicitly.

Steps To Reproduce

  1. create a project like described above
  2. run dbt parse

Relevant log output

dbt.log

08:26:10.446302 [info ] [MainThread]: Manifest loaded
08:26:10.458008 [debug] [MainThread]: Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'end', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7fe7b80dca90>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7fe7b80dc490>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7fe7b80dc3a0>]}
08:26:10.458492 [debug] [MainThread]: Flushing usage events
08:26:11.061893 [error] [MainThread]: Encountered an error:
Compilation Error
  dbt found two models with the name "TaxTrans".

  Since these resources have the same name, dbt will be unable to find the correct resource
  when looking for ref("TaxTrans").

  To fix this, change the name of one of these resources:
  - model.databricks_dwh.TaxTrans (models/Finance/TaxTrans.sql)
  - model.source_ax12.TaxTrans (models/source_ax12/TaxTrans.sql)

Environment

- OS: Debian 11
- Python: 3.9.2
- dbt: 1.4.1

Which database adapter are you using with dbt?

spark

Additional Context

No response

jtcohen6 commented 1 year ago

@leo-schick Thanks for opening! I share your instincts about what's desirable here.

This is a quite old issue:

The good news is, we're planning to (finally) tackle that work, a few months from now, as part of a larger initiative:

In the meantime, I'm going to close this as a duplicate of #1269.