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

[Bug] Unit tests don't recognize versioned sources #11039

Closed
2 tasks done
gnilrets opened this issue Nov 22, 2024 · 3 comments
Closed
2 tasks done

[Bug] Unit tests don't recognize versioned sources #11039

gnilrets opened this issue Nov 22, 2024 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists model_versions unit tests Issues related to built-in dbt unit testing functionality

Comments

@gnilrets
Copy link

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

I have a test that depends on a model that is versioned, but when I run the test, I get an error that the node cannot be found.

For example, in my unit test I have:

unit_tests:
  - name: test_fct_nerc_core__unpatched
    model: fct_nerc_core__unpatched

    given:
      - input: ref('fct_outage')
        # blah....

The fct_outage model is versioned, and I removed the v1 version a while ago, so I just have:

fct_outage_v2.sql
fct_outage.yml

The fct_outage.yml model is defined as

models:
  - name: fct_outage
    latest_version: 2
   #....
    versions:
      - v: 2

When I run the unit test, I get:

23:22:59    Compilation Error in unit_test test_fct_nerc_core__unpatched (models/marts/customer/int/fct_nerc_core__unpatched.yml)
  Unit_Test 'unit_test.eta_wh.fct_nerc_core__unpatched.test_fct_nerc_core__unpatched' (models/marts/customer/int/fct_nerc_core__unpatched.yml) depends on a node named 'fct_outage' which was not found

However, if I remove versions from fct_outage.yml and rename fct_outage_v2.sql to fct_outage.sql, the unit test works.

Expected Behavior

We should be able to run unit tests that depend on models that are versioned.

Steps To Reproduce

  1. Create a unit test for a model that depends on a versioned model.
  2. Run the unit test.

Relevant log output

No response

Environment

- OS: Debian GNU/Linux 12 (bookworm)
- Python: Python 3.10.15
- dbt: 1.8.5

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

@gnilrets gnilrets added bug Something isn't working triage labels Nov 22, 2024
@dbeatty10 dbeatty10 added model_versions unit tests Issues related to built-in dbt unit testing functionality labels Nov 24, 2024
@dbeatty10
Copy link
Contributor

Thanks for reaching out @gnilrets !

We just merged #10889 a little over a week ago, and it will be included in dbt-core v1.9, and it looks to me like it would solve the issue you are reporting here.

Here are the other descriptions of the issue:

Could you give these a look and see if they describe the same thing that you experienced?

@gnilrets
Copy link
Author

That's it. I missed those bugs because I was only searching for open bugs. Thanks!

@dbeatty10
Copy link
Contributor

Okay! I'm going to close this in favor of those.

Please reach out if #10889 doesn't solve it for you 🙏

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2024
@dbeatty10 dbeatty10 added duplicate This issue or pull request already exists and removed triage labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists model_versions unit tests Issues related to built-in dbt unit testing functionality
Projects
None yet
Development

No branches or pull requests

2 participants