z3z1ma / dbt-osmosis

Provides automated YAML management, a dbt server, streamlit workbench, and git-integrated dbt model output diff tools
https://z3z1ma.github.io/dbt-osmosis/
Apache License 2.0
422 stars 45 forks source link

Different models with same alias causing issues #27

Closed darious closed 1 year ago

darious commented 1 year ago

dbt version 1.3.0 dbt-osmosis version 0.9.7

When running dbt-osmosis yaml refactor on my project it results in duplicates, i.e. the same model in multiple yaml files. This seems be caused by having multiple models with different names, but the same alias (in different schemas). The yml files are named correctly, i.e. same as the model, but the model name inside the schema.yml is the alias not the model name. This then leads to failures.

jaredx435k2d0 commented 1 year ago

Getting the same thing here:

dbt.exceptions.CompilationException: Compilation Error
  dbt found two schema.yml entries for the same resource named [my_model_name_redacted]. Resources and their associated columns may only be described a single time. To fix this, remove the resource entry for [my_model_name_redacted] in one of these files:
   - models/marts/[my_folder_name_redacted]/schema.yml
  models/marts/[my_folder_name_redacted]/schema.yml

The models have distinct names, but I'm using the "alias" config in one of them, because the resulting tables in the database actually have the same name. This is because they are in different schemas. I have a number of situations like this.

dbt-core==1.3.2 dbt-extractor==0.4.1 dbt-osmosis==0.9.8 dbt-snowflake==1.3.0

Python 3.10.9 macOS 13.2 (22D49)

Using Snowflake 7.2.0

jaredx435k2d0 commented 1 year ago

For me, this unfortunately is a hard stop and prevents me from benefiting from the YAML management piece of this project at all, which is a huge shame; I absolutely love the idea and wish I could take advantage.

z3z1ma commented 1 year ago

This should be resolved. There was a point in the code path we were using something like node.alias or node.name but it should have been using node.name exclusively without the short circuit.

jaredx435k2d0 commented 1 year ago

Love all these improvements! 🥳