Skip to content
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

[CT-3030] [Bug] Ambiguous reference error for versions when model name is duplicated across packages #8493

Closed
2 tasks done
MichelleArk opened this issue Aug 24, 2023 · 0 comments · Fixed by #8488
Closed
2 tasks done
Assignees
Labels
backport 1.6.latest bug Something isn't working model_versions packages Functionality for interacting with installed packages

Comments

@MichelleArk
Copy link
Contributor

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Very similar to #8327

When:

  • a model with the same name is defined in multiple projects
  • those projects are installed in the same runtime environment (via packages)
  • at least one of those models has a version defined
    dbt raises an ambiguous reference error

Expected Behavior

dbt should successfully parse my project, and resolve version definitions to reference the model in the same project/package where they are defined

Steps To Reproduce

Create a project named my_dbt_project, and another local project under a subdirectory named mypkg/.

Within the root project:

# dbt_project.yml
name: my_dbt_project
profile: default
# dependencies.yml OR packages.yml
packages:
  - local: mypkg
-- models/model_a.sql
select 1 as id
# models/config.yml
models:
  - name: model_a
    versions:
     - v: 1

Within the package mypkg, add the exact same model with the exact same config:

# mypkg/dbt_project.yml
name: mypkg
-- mypkg/models/model_a.sql
select 1 as id
# mypkg/models/config.yml
models:
  - name: model_a
    versions:
     - v: 1

From the root project:

$ dbt deps
14:10:31  Running with dbt=1.6.0
14:10:31  Installing mypkg
14:10:31  Installed from <local @ mypkg>

$ dbt --no-partial-parse parse
14:10:43  Running with dbt=1.6.0
14:10:43  Registered adapter: postgres=1.6.0
14:10:44  Encountered an error:
Compilation Error
  When referencing 'model_a', dbt found nodes in multiple packages: 'model.my_dbt_project.model_a', 'model.mypkg.model_a'
  To fix this, use two-argument 'ref', with the package name first: 'my_dbt_project' or 'mypkg'

Remove the unique tests, then parse again (this time successfully):

$ dbt --no-partial-parse parse
14:11:23  Running with dbt=1.6.0
14:11:24  Registered adapter: postgres=1.6.0
14:11:24  Performance info: /Users/jerco/dev/scratch/testy/target/perf_info.json

Environment

- OS: macOS Ventura 13.4.1
- Python: 3.10.11
- dbt: 1.6.0

Relevant log output

No response

Environment

- OS:
- Python:
- dbt:

Which database adapter are you using with dbt?

No response

Additional Context

No response

@MichelleArk MichelleArk added bug Something isn't working packages Functionality for interacting with installed packages model_versions labels Aug 24, 2023
@github-actions github-actions bot changed the title [Bug] Ambiguous reference error for versions when model name is duplicated across packages [CT-3030] [Bug] Ambiguous reference error for versions when model name is duplicated across packages Aug 24, 2023
@MichelleArk MichelleArk self-assigned this Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.6.latest bug Something isn't working model_versions packages Functionality for interacting with installed packages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants